aes

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

☆樱花仙子☆ 提交于 2019-12-12 08:59:23
问题 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. 回答1:

AES equivalent in Ruby openssl?

倖福魔咒の 提交于 2019-12-12 08:51:27
问题 Gibberish library provides a nice CBC algo... // In Jascascript GibberishAES.enc("Made with Gibberish\n", "password"); // Outputs: "U2FsdGVkX1+21O5RB08bavFTq7Yq/gChmXrO3f00tvJaT55A5pPvqw0zFVnHSW1o" # On the command line echo "U2FsdGVkX1+21O5RB08bavFTq7Yq/gChmXrO3f00tvJaT55A5pPvqw0zFVnHSW1o" | openssl enc -d -aes-256-cbc -a -k password How can I do this decryption in ruby? The straightforward way doesn't work... require 'openssl' def aes(m,k,t) (aes = OpenSSL::Cipher::Cipher.new('aes-256-cbc')

Java AES decryption BadPaddingException

心已入冬 提交于 2019-12-12 08:16:49
问题 note: Java NOOB. Alright, I know this has been answered a few dozen times on here, but the solutions don't seem to work/apply directly to where I understand them. (Yes, I know I don't completely understand encryption/decryption, AES, etc. but that is not the point, I am trying to understand this) I have a utility api where I want to pass a string and return an encrypted string. Then I want to pass the encrypted string, and return a decrypted string. Simple. It works fine for many strings I

How to encrypt data using AES in Java

别说谁变了你拦得住时间么 提交于 2019-12-12 07:57:03
问题 I wish to encrypt a piece of data using AES (cbc) in java , I Want to use my own IV, which I have held in a byte array and my own key held in a byte array. How would I go about doing this? I'm searching for it to find tutorials on this topic. 回答1: This is probably the best guide that I've found on the subject. It explains the basics, one concept at a time, in simple terms. 回答2: Formally it encrypts the string into unreadable format. Use same code to decrypt. ENCRYPT: String s1="arshad"; char[

How to encrypt / decrypt AES with Libsodium-PHP

我与影子孤独终老i 提交于 2019-12-12 07:49:28
问题 I need to encrypt/decrypt data with PHP. I am completely new to this, however I have read that Libsodium-PHP is the best tool for AES encryption. Much like the other PHP encryption libraries I have researched Libsoduim-PHP seemed to offer almost no documentation of how to use the library (that I was able to find). Can anyone that has experience with PHP encryption either point me in the direction of a good learning resource or write a few lines of sample code using Libsoduim-PHP? Thank you

PHP Java AES CBC Encryption Different Results

隐身守侯 提交于 2019-12-12 07:31:06
问题 PHP Function: $privateKey = "1234567812345678"; $iv = "1234567812345678"; $data = "Test string"; $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $privateKey, $data, MCRYPT_MODE_CBC, $iv); echo(base64_encode($encrypted)); Result: iz1qFlQJfs6Ycp+gcc2z4w== Java Function public static String encrypt() throws Exception{ try{ String data = "Test string"; String key = "1234567812345678"; String iv = "1234567812345678"; javax.crypto.spec.SecretKeySpec keyspec = new javax.crypto.spec.SecretKeySpec

Decode OpenSSL AES256 string in iOS

纵然是瞬间 提交于 2019-12-12 07:21:54
问题 CLI $ echo -n "TEST1" | openssl enc -aes256 -k FUUU -nosalt -a bYbkQJcDFZt3y3UQEMbEeg== iOS NSString *leSYT = @"bYbkQJcDFZt3y3UQEMbEeg=="; NSData *data = [NSData dataFromBase64String:leSYT]; NSLog(@"%@",[data AES256DecryptWithKey:@"FUUU"]); iOS doesn't output anything since it failed. What am I missing? NSData additions: http://pastie.org/426530 // NSData+Base64 by Matt Gallagher 回答1: The -k option in OpenSSL's enc utility derives an AES key and IV from your passphrase "FUUU". You can use the

Encryption mismatch between Java and PHP

删除回忆录丶 提交于 2019-12-12 07:16:50
问题 I'm working on an encryption system that passes the data to a 3rd party application. The encryption is done in Java and the decryption is done in PHP. Despite several attempts I can't get the encrypted string to be opened by the PHP application. For testing purposes I created a PHP script that also encrypts the data, so I could compare the Java and PHP encrypted strings. The results match up to the 21st character, and then they differ. This is what I have: // Java - Encrypt private String

PHP ColdFusion9 AES Encryption - Different results

喜欢而已 提交于 2019-12-12 07:07:19
问题 AES Encryption in PHP and ColdFusion9 is producing different results. Could somebody please help me? The below PHP Code $key = "12345678123456781234567812345678"; $iv = "1234567812345678"; $data = "This is a plain string."; echo base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv)); gives me G+tdEOfQTtVCQGxW3N5uzkqN207OyfIPxS6zf2xrKKY= While the below ColdFusion Code <cfset thePlainData = "This is a plain string." /> <cfset theKey =

Incompatible AES implementations?

折月煮酒 提交于 2019-12-12 06:22:56
问题 I've compiled some AES implementation code from this site, it's supposed to perfrom a 128 bits key encryption. I tested the encryption/decryption programs which work OK together. However if I encrypt anything with the mentioned code and then try to decrypt it by openssl tool built-in in linux, I just can't get decrypt it, it even logs me the bad magic number error. Same, if I encrypt anything with openssl and try to decrypt with the code won't work. I tried with both cbc ecb. If they're both