aes

Android-AES加解密

久未见 提交于 2020-01-25 21:59:27
项目Aes功能背景: 早期用的是jni写的aes加密算法,其实android 本身就实现了aes算法。 于是封装了一个工具类(实际元素值要变,比如加密模式,偏移量等等),这里写法只是参考,封装的有点欠妥,但思路简介易懂,可以随手修改。 加密在线链接 做这块要与服务器的算法一致才是可以,所以要对以上的元素(加密模式,填充、数据块,偏移量等元素,仔细校验。) 偏移量最少:16字节长度 那就是填0000000000000000 import android . util . Base64 ; import javax . crypto . Cipher ; import javax . crypto . spec . IvParameterSpec ; import javax . crypto . spec . SecretKeySpec ; /** * * android 对应的aes 工具 --- 可以替换本项目中的jni aes * @author bingley * @date 2020/1/13. */ public class AESUtils { public static String algorithm = "AES/CBC/PKCS5Padding" ; //使用的算法 算法/模式/补码方式, 目前支持ECB和CBC模式 public static String

How to write AES cipher text to an image

我的未来我决定 提交于 2020-01-25 19:14:52
问题 In the process of image encryption using AES, when the pixel values are read and when the AES encryption applied, the cipher text results in some negative values. How is it possible to frame an encrypted image from these kind of negative values i.e., cipher text? 来源: https://stackoverflow.com/questions/33776494/how-to-write-aes-cipher-text-to-an-image

How to write AES cipher text to an image

一曲冷凌霜 提交于 2020-01-25 19:12:06
问题 In the process of image encryption using AES, when the pixel values are read and when the AES encryption applied, the cipher text results in some negative values. How is it possible to frame an encrypted image from these kind of negative values i.e., cipher text? 来源: https://stackoverflow.com/questions/33776494/how-to-write-aes-cipher-text-to-an-image

AES - Crypto JS & PHP

坚强是说给别人听的谎言 提交于 2020-01-25 15:32:32
问题 I've problem with decryption data encrypted in cryptojs. Sometimes it works sometimes not, if works it returns "Message", but if dosent it returns garbage. var salt = CryptoJS.lib.WordArray.random(128/8); var key256Bits500Iterations = CryptoJS.PBKDF2("password", salt, { keySize: 256/32, iterations: 5 }); var iv = CryptoJS.enc.Hex.parse('1011121c1d1e1f'); var encrypted = CryptoJS.AES.encrypt("Message", key256Bits500Iterations, { iv: iv }); var data_base64 = encrypted.ciphertext.toString

Problem with MySQL's AES_DECRYPT

偶尔善良 提交于 2020-01-24 19:36:12
问题 I'm looking for a way to encrypt data on its way into a MySQL database, and decrypt it on the way out. Additionally, I would like to be able to perform normal SQL queries on those fields, such as searching and comparison, which prevents me from using a pure PHP solution. This leads me to AES_ENCRYPT() and AES_DECRYPT(), which can be duplicated in PHP using MCRYPT. I'm having a hard time with AES_DECRYPT and have tried all suggestions I can find through searches online. Here's my table: CREATE

PHP AES加密解密。

拟墨画扇 提交于 2020-01-24 15:19:42
<?php namespace app\models; class AES { public $key; //构造函数,用密钥初始化 function Prpcrypt( $k ) { $this->key = $k; } /*AES加密*/ public static function encrypt($input, $key = '') { $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $input = AES::pkcs5_pad($input, $size); $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $key, $iv); $data = mcrypt_generic($td, $input); mcrypt_generic_deinit($td); mcrypt_module_close($td); $data = base64_encode($data); return $data; }

PHP进行AES/ECB/PKCS7 padding加密的例子(mcrypt)

女生的网名这么多〃 提交于 2020-01-24 11:07:15
业务需要,需要对数据进行加密( AES/ECB/PKCS7Padding ),由于之前对该内容了解较少,于是去网上搜寻答案,很庆幸,很快搜索到一个例子,基本不用改动什么就可以使用,但是里面有不少内容还不是很了解,现在把它记下来日后慢慢学习。 <?php class AES { protected $cipher; protected $mode; protected $pad_method; protected $secret_key; protected $iv; public function __construct($key, $method = 'pkcs7', $iv = '', $mode = MCRYPT_MODE_ECB, $cipher = MCRYPT_RIJNDAEL_128) { $this->secret_key = $key; $this->pad_method =$method; $this->iv = $iv; $this->mode = $mode; $this->cipher = $cipher; } protected function pad_or_unpad($str, $ext) { if (!is_null($this->pad_method)) { $func_name = __CLASS__ . '::' . $this->pad

OpenSSL::Cipher::CipherError when running staging DB on local

試著忘記壹切 提交于 2020-01-24 04:08:30
问题 I just copied our staging server database into my development, and now I receive this error whenever I load any data OpenSSL::Cipher::CipherError Which occurs at the following piece of code credentials = encrypted_credentials.inject({}) do |hash, (key, value)| hash[key] = AESCrypt.decrypt(value, password) <----------- hash end Anybody have a clue why this is? 回答1: Turned out I was using the wrong encryption password, because it was stored in a environment variable 来源: https://stackoverflow

Python 的AES加密与解密

回眸只為那壹抹淺笑 提交于 2020-01-23 18:24:48
Python 的AES加密与解密 AES加密方式有五种:ECB, CBC, CTR, CFB, OFB 从安全性角度推荐CBC加密方法,本文介绍了CBC,ECB两种加密方法的python实现 python 在 Windows 下使用AES时要安装的是pycryptodome 模块 pip install pycryptodome python 在 Linux 下使用AES时要安装的是pycrypto模块 pip install pycrypto CBC加密需要一个十六位的key(密钥)和一个十六位iv(偏移量) ECB加密不需要iv AES CBC 加密的python实现 1 from Crypto.Cipher import AES 2 from binascii import b2a_hex, a2b_hex 3 4 5 # 如果text不足16位的倍数就用空格补足为16位 6 def add_to_16(text): 7 if len(text.encode('utf-8')) % 16: 8 add = 16 - (len(text.encode('utf-8')) % 16) 9 else: 10 add = 0 11 text = text + ('\0' * add) 12 return text.encode('utf-8') 13 14 15 # 加密函数 16

Parallel simulation of AES in C using Openmp

一曲冷凌霜 提交于 2020-01-23 16:22:05
问题 Here is my problem. I want to parallelize AES-128 encryption in C using Openmp. I am hardly getting any speedup with the following code using openmp. My machine is Quadcore intel i5 machine. Here is the code. Any suggestion how to parallelize this code further would be really really appreciated. Please take a look at the main function which is at the end of the code. AES code below consists of a few functions to achieve its functionality. Please suggest how to best extract parallelism from