aes

Crypto++ encrypt and decrypt in two different c++ programs

你离开我真会死。 提交于 2019-11-30 20:27:59
问题 I am writing a code to encrypt and decrypt with crypto++ library .I found a code to encrypt and decrypt which is shown below.The code works OK as one program.but when I divide into two c++ programs (One for encryption and another for decryption) the decryption pargram gives me error terminate called after throwing an instance of 'CryptoPP::InvalidCiphertext' what(): StreamTransformationFilter: ciphertext length is not a multiple of block size The ciphertext I get after encryption is ���z=(f��

Decrypting AES with Javascript CryptoJS after encrypting with PHP mcrypt

末鹿安然 提交于 2019-11-30 19:59:56
问题 Encrypting in PHP with mcrypt <?php $string = 'Secret Message'; $key = 'd4b494e4502a62edd695a903a94c2701'; $iv = '02f30dffbb0d084755f438f7d8be4a7d'; $encrypted = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv ) ); //$encrypted results in 'nYoFAiyDARVSI09lH/IPdim5TvE51izVjk6sc2AK9Rg=' ?> Decrypting in Javascript with CryptoJS <script> var encrypted = 'nYoFAiyDARVSI09lH/IPdim5TvE51izVjk6sc2AK9Rg='; var key = CryptoJS.enc.Hex.parse(

PHP iOS AES Encryption

牧云@^-^@ 提交于 2019-11-30 19:47:23
I've been having trouble trying to communicate between PHP and my iOS application using AES encryption. So far, I've considered two methods of implementation. The first was to use OpenSSL. On the iOS side, I implemented in a way to mimic the code shown here: http://saju.net.in/code/misc/openssl_aes.c.txt . On the PHP side, I took the generated key and IV (from the iPhone) and used it as input to the PHP openssl encrypt. The results differed in terms of the output... I have also considered: http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html but this SO

Objective-C decrypt AES 128 cbc hex string

◇◆丶佛笑我妖孽 提交于 2019-11-30 19:25:17
问题 I am developing an application for iPhone on Snow Leopard with Xcode 3.1 that receives from a restful web service an encrypted text in hexadecimal format with the algorithm AES 128-bit (CBC). The algorithm uses an initialization vector + secret key. How do I decrypt this text? Thanks to everyone for the tips that I will succeed in giving. EDIT: I get response from REST Server in hex AND crypted format,I try with this code but i receive always bad param error. Can you help me to find the error

AES Gingerbread

為{幸葍}努か 提交于 2019-11-30 18:41:12
问题 This is my code for AES. Under Gingerbread I get following error after encrypting the data on 2.2 then trying to decrypt on 2.3: Caused by: javax.crypto.BadPaddingException: pad block corrupted at org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(JCEBlockCipher.java:715) at javax.crypto.Cipher.doFinal(Cipher.java:1090) at com.citc.wallet.util.security.SimpleCrypto.decrypt(SimpleCrypto.java:63) ... 21 more I have found some posts saying that SecureRandom is producing different results

MySQL - How to store AES_Encrypted data?

你离开我真会死。 提交于 2019-11-30 17:28:26
So I have been browsing the internet, and came across the MySQL built-in function AES_ENCRYPT. It doesn't seem too hard to use, but some sources tell me to store the encrypted data as a VARCHAR, and some say to store it as a BLOB. What should I store the encrypted data as? Many encryption and compression functions return strings for which the result might contain arbitrary byte values. If you want to store these results, use a column with a VARBINARY or BLOB binary string data type. This will avoid potential problems with trailing space removal or character set conversion that would change

how to use OpenSSL to decrypt Java AES-encrypted data?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 17:04:12
I'm interfacing to a legacy Java application (the app cannot be changed) which is encrypting data using AES. Here is how the original Java code is instantiating the AES cipher: SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec ); I'm a C/C++ developer, not Java, but from what I can tell this legacy Java code is not specifying the mode, nor the initialization vector. Anyone happen to know what Java would be using by default since it isn't specified? We need the new C/C++ app to decrypt the Java-encrypted data.

Exception in AES decryption algorithm in java

牧云@^-^@ 提交于 2019-11-30 16:45:44
This is the code for encrypting and decrypting a string in java using AES algorithm. Its throwing illegalblocksize exception while decrypting. I know it is occuring because length of input string to the decryption method isn't matching with the padding. I don't have an idea of how to solve this. I am a new bie to the encryption decryption. Plz help me.... StackTrace: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..) at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..) at com.sun.crypto

bytes in 'str = new String(bytes, “UTF8”) ' and 'bytes = str.getBytes(“UTF8”)' not the same value

旧街凉风 提交于 2019-11-30 16:45:44
I can see they are different than the bytes I created the string with! I have used "AES/CBC/PKCS5Padding" to get the string. public static void main(String[] args) { try { int randomNumber = CNStationQueueUtil.randInt(0, 99999); String key = "AES_KEY_TAKENUMB"; byte[] bytes = EncryptHelper.encrypt(key, String.format("%%%d%%%d", 1001, randomNumber)); String str = new String(bytes, "UTF8"); System.out.println("str = " + str); System.out.println(); byte[] utf8Bytes = str.getBytes("UTF8"); printBytes(utf8Bytes, "utf8Bytes"); } catch (Exception e) { e.printStackTrace(); } } public class

AES 256 Encryption Issue

99封情书 提交于 2019-11-30 16:45:37
The following code perfectly implements AES-128 encryption/decryption. public static void main(String[] args) throws Exception { String input = JOptionPane.showInputDialog(null, "Enter your String"); System.out.println("Plaintext: " + input + "\n"); // Generate a key KeyGenerator keygen = KeyGenerator.getInstance("AES"); keygen.init(128); byte[] key = keygen.generateKey().getEncoded(); SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); // Generate IV randomly SecureRandom random = new SecureRandom(); byte[] iv = new byte[16]; random.nextBytes(iv); IvParameterSpec ivspec = new