aes

Java decryption of an encrypted file with openssl aes 256 cbc

痴心易碎 提交于 2019-11-30 16:43:50
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 understood that openssl did it by default. When I try to decipher,

Decrypt AES256 encrypted bytes

核能气质少年 提交于 2019-11-30 16:40:53
I've never worked with encryption before. Actually I know nothing about encryption. I have a file encrypted with openssl tool using params: openssl aes-256-cbc -nosalt -in fileIn -out fileOUT -p -k KEY I need to decrypt it into memory but I don't know how. Can anyone provide me the code related to encryption? Here's class I have written to decrypt a string encoded with params above (if I remmeber it correct): public class CipherUtils { public static byte[] getKey(String password, byte[] salt) { try { byte[] passwordSalt = EncodingUtils.getAsciiBytes(password); passwordSalt =

android AES encryption/ decryption

萝らか妹 提交于 2019-11-30 16:39:56
I have managed to code the function for doing file encryption / decryption . But its very slow especially as the file size increase. for eg audio / vidoe file which are few MB long I have gone through almost all post to improve it, and tried changing the algorthms. Please help me if there is any change that can help me improve performance. public class DataEncryptDecrypt { public Cipher encryptcipher, decryptCipher; int blockSize = 16; String TAG = "DataEncryptDecrypt"; private static final String RANDOM_ALGORITHM = "SHA1PRNG"; public DataEncryptDecrypt(String passwd) { final String

Java AES 256 encryption

流过昼夜 提交于 2019-11-30 16:29:35
I have the below java code to encrypt a string which uses a 64 character key. My question is will this be a AES-256 encryption? String keyString = "C0BAE23DF8B51807B3E17D21925FADF273A70181E1D81B8EDE6C76A5C1F1716E"; byte[] keyValue = hexStringToByte(keyString); Key key = new SecretKeySpec(keyValue, "AES"); Cipher c1 = Cipher.getInstance("AES"); c1.init(Cipher.ENCRYPT_MODE, key); String data = "Some data to encrypt"; byte[] encVal = c1.doFinal(data.getBytes()); String encryptedValue = Base64.encodeBase64String(encVal); /* Copied the below code from another post in stackexchange */ public static

Encryption mismatch between Java and PHP

纵然是瞬间 提交于 2019-11-30 16:22:45
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 EncryptAES(String text,String key) throws Exception { SecretKeySpec skeySpec = new SecretKeySpec(key

Decrypt AES256 encrypted bytes

自闭症网瘾萝莉.ら 提交于 2019-11-30 16:20:30
问题 I've never worked with encryption before. Actually I know nothing about encryption. I have a file encrypted with openssl tool using params: openssl aes-256-cbc -nosalt -in fileIn -out fileOUT -p -k KEY I need to decrypt it into memory but I don't know how. Can anyone provide me the code related to encryption? 回答1: Here's class I have written to decrypt a string encoded with params above (if I remmeber it correct): public class CipherUtils { public static byte[] getKey(String password, byte[]

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

 ̄綄美尐妖づ 提交于 2019-11-30 16:19:43
问题 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

Simple AES encryption using WinAPI

自作多情 提交于 2019-11-30 15:33:01
问题 I need to do simple single-block AES encryption / decryption in my Qt / C++ application. This is a "keep the honest people honest" implementation, so just a basic encrypt(key, data) is necessary--I'm not worried about initialization vectors, etc. My input and key will always be exactly 16 bytes. I'd really like to avoid another dependency to compile / link / ship with my application, so I'm trying to use what's available on each platform. On the Mac, this was a one-liner to CCCrypt . On

AesManaged Decryption in Metro WinRT application

故事扮演 提交于 2019-11-30 15:22:08
I have some text, encrypted by C#'s AesManaged, which must be decrypted in a WinRT Metro application. I cannot change the Encryption code, as the code has other dependencies which cant be changed. The encryption function looks like this: // Note: Edited out possibly real password and salt: Guid password = Guid.Parse("AAAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"); Guid salt = Guid.Parse("AAAAAAAAA-BBBB-BBBB-BBBB-AAAAAAAAAAAA"); string EncryptedValue(string data) { byte[] passwordBytes = password.ToByteArray(); byte[] saltBytes = salt.ToByteArray(); byte[] bKey = new byte[16]; for(int i = 0; i < 16; i

AES Encryption .net to swift

江枫思渺然 提交于 2019-11-30 14:31:02
问题 .Net Code : public string AESEncrypt(string clearText,string key) { string EncryptionKey = key; // "MAKV2SPBNI99212"; byte[] clearBytes = Encoding.Unicode.GetBytes(clearText); using (Aes encryptor = Aes.Create()) { int iterations = 1024; Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 }, iterations); encryptor.Key = pdb.GetBytes(32); encryptor.IV = pdb.GetBytes(16); using (MemoryStream ms