aes

Openssl AES 256 CBC Java Decrypt File with salt

旧城冷巷雨未停 提交于 2019-12-04 21:01:04
I have been trying for several days to decrypt in java a message encrypted with openssl. The message was encrypted with the following command: openssl enc -e -aes-256-cbc -kfile $ file.key -in toto -out toto.enc. The file file.key contains the symmetric key of 256 bits. No salt has been specified in the command and yet the file begins with Salted__. Here is the class that I coded to try to decrypt the file but impossible to get anything even by removing the 16 characters of the file namely the: Salted__ + the salt encrypted. I get the error: Exception in thread "main" javax.crypto

does ruby-aes use padding by default?

感情迁移 提交于 2019-12-04 20:40:16
I am using the following in a RoR project: somepass =Aes.encrypt_buffer(128, 'ECB', some_cypher_key, nil, pain_string) Does using this lib and method ECB use padding by default or not? What I am ultimately trying to do is have a RoR app and a Java app be able to create the same encrypted string out of the same simple string. In Java code I use: cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE"); These two lines of code do not create the same encrypted key. Aes.encrypt_buffer will use padding, just not that kind that you are expecting. It will pad the block with n bytes with the

perl CBC DES equivalent in java

佐手、 提交于 2019-12-04 20:34:02
This question was migrated from Information Security Stack Exchange because it can be answered on Stack Overflow. Migrated 5 years ago . We are migrating some code from perl to java/scala and we hit a roadblock. We're trying to figure out how to do this in Java/scala: use Crypt::CBC; $aesKey = "some key" $cipher = new Crypt::CBC($aesKey, "DES"); $encrypted = $cipher->encrypt("hello world"); print $encrypted // prints: Salted__�,%�8XL�/1�&�n;����쀍c $decrypted = $cipher->decrypt($encrypted); print $decrypted // prints: hello world I tried a few things in scala but didn't really get it right, for

AES with CommonCrypto uses too much memory - Objective-C

試著忘記壹切 提交于 2019-12-04 20:16:03
问题 My goal is to be able to, being given a file/folder and a password, encrypt and decrypt it in AES using Objective-C. I'm no crypto nerd or anything, but I chose AES because I found it was pretty standard and very secure. I am using a NSMutableData category which has methods for encrypting and decrypting it's data. Here it is: - (NSInteger)AES256EncryptionWithKey: (NSString*)key { // The key should be 32 bytes for AES256, will be null-padded otherwise char keyPtr[kCCKeySizeAES256 + 1]; // room

密码 | 对称加密 - AES

北城余情 提交于 2019-12-04 20:00:49
AES 算法简介 高级加密标准(英语:Advanced Encryption Standard,缩写:AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准,用来替换原先的 DES. 背景介绍:1997年1月2号,美国国家标准技术研究所(National Institute of Standards and Technology: NIST)宣布希望征集高级加密标准(Advanced Encryption Standard: AES),用以取代DES。AES得到了全世界很多密码工作者的响应,先后有很多人提交了自己设计的算法。最终有5个候选算法进入最后一轮: Rijndael , Serpent , Twofish , RC6 和MARS。最终经过安全性分析、软硬件性能评估等严格的步骤,Rijndael算法获胜。 AES 算法的区块长度固定为128位(16 字节),密钥长度则可为128位,192位,256位。加密模式可采用 ECB,CBC,CTR,OFB,CFB 等模式进行加密。 其中 ECB 与 CBC 模式是对数据原文做加密处理,原文长度的必须为 16 或 16 的倍数方可加密成功,不足16倍数的部分则需进行 Padding 处理(Padding 方式为 PKCS5 Padding 或 PKCS7 Padding)。 CTR,OFB,CFB

How do you use AES to Encrypt in One Program, Decrypt in Another

﹥>﹥吖頭↗ 提交于 2019-12-04 19:55:16
I was told not to use RSA to encrypt simple text but to use AES. I found a simple piece of code to implement AES: public static class Crypto { #region Settings private static int _iterations = 2; private static int _keySize = 256; private static string _hash = "SHA1"; private static string _salt = "aselrias38490a32"; // Random private static string _vector = "8947az34awl34kjq"; // Random #endregion public static string Encrypt(string value, string password) { return Encrypt<AesManaged>(value, password); } public static string Encrypt<T>(string value, string password) where T :

SOAP response MTOM attachment can't be decrypted (AES algorithm)

*爱你&永不变心* 提交于 2019-12-04 19:29:12
I'm working on the soap client and have a problem with reading (and decryption) of the response attachment. The attachment is included into the the response using MTOM mechanism and encrypted via AES128-CBC algorithm (the secret key is included to the response xml header). Here is the basic structure of the response: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope> .. the xml data that includes the secret key for the attachment decryption usign AES algorithm. </soapenv:Envelope> --MIMEBoundaryurn_uuid_174A74CB7221A5AF451426570004765 Content-Type: application/octet-stream Content

AES decryption with bouncy castle

£可爱£侵袭症+ 提交于 2019-12-04 19:29:07
I am attempting to adapt the sample code at http://www.java2s.com/Code/Java/Security/Basicsymmetricencryptionexample.htm to have to be invoked with 3 arguments, the mode (encryption or decryption), IV and the key. It also reads and writes to specific files. As of right now I am ignoring the given IV and key until I get the rest up and running. My code successfully encrypts plaintext from a file, and writes the ciphertext to a file, but the decryption does not work. It appears that decryption mode reads in more bytes than encryption wrote and I get block alignment errors. I'm sure there is some

AES加密CBC模式兼容互通四种编程语言平台【PHP、Javascript、Java、C#】

荒凉一梦 提交于 2019-12-04 19:16:03
由于本人小菜,开始对AES加密并不了解,在网络上花了比较多时间查阅资料整理; 先简单从百度找来介绍: 密码学中的高级加密标准(Advanced Encryption Standard,AES),又称高级加密标准Rijndael加密法, 是美国联邦政府采用的一种区块加密标准。这个标准用来替代原先的DES,已经被多方分析且广为全世界 所使用。经过五年的甄选流程,高级加密标准由美国国家标准与技术研究院 (NIST)于2001年11月26日 发布于FIPS PUB197,并在2002年5月26日成为有效的标准。2006年,高级加密标准已然成为对称密钥加密 中最流行的算法之一。该算法为比利时密码学家Joan Daemen和VincentRijmen所设计,结合两位作者的名 字,以Rijndael之命名之,投稿高级加密标准的甄选流程。(Rijdael的发音近于 "Rhinedoll"。) AES加密模式和填充方式(其实还有还几种填充方式没写上,开始时候也在这里绕了一下) 算法/模式/填充 16字节加密后数据长度 不满16字节加密后长度 AES/CBC/NoPadding 16 不支持 AES/CBC/PKCS5Padding 32 16 AES/CBC/ISO10126Padding 32 16 AES/CFB/NoPadding 16 原始数据长度 AES/CFB/PKCS5Padding

How to correctly encrypt data with proper authentication using AES-256-CBC in php?

点点圈 提交于 2019-12-04 19:10:58
I have been using the openssl function for encrypting data with AES-256-CBC in php. I have been able to encrypt it using an unique IV (by generating with openssl_random_pseudo_bytes)for each new encryption. But I am struggling with the idea of authenticated encryption with aes cbc. How do I basically authenticate when I am about to decrypt the data? Do I need to use something like PBKDF2, blowfish or hash_hmac()? Do I need to hash the key somehow? Any help is extremely appreciated. Simple solution, use RNCryptor which is available for php and many other languages. See this ReadMe for