The following encryption and decryption work normally in mysql (aes-256-cbc) mode
SET block_encryption_mode = 'aes-256-cbc'; select cast( aes_decrypt( from_base64('StThdNXA+CWvlg+of/heJQ=='), sha2(concat('ssshhhhhhhhhhh!!','ENCRYPTION_KEY$&'),256), 'ssshhhhhhhhhhh!!' ) as char); select to_base64(aes_encrypt( 'test_value', sha2(concat('ssshhhhhhhhhhh!!','ENCRYPTION_KEY$&'),256), 'ssshhhhhhhhhhh!!' ));
I'm trying to decrypt a value encrypted in mysql without success.
The following is the key in my mysql query sha256 (salt key)
select sha2(concat('ssshhhhhhhhhhh!!','ENCRYPTION_KEY$&'),256);
Same value as I was able to get in java:
Hashing.sha256().hashString("ssshhhhhhhhhhh!!ENCRYPTION_KEY$&", StandardCharsets.UTF_8).toString();
Is there a custom way to make bouncy castle/other APIs use the same key for decryption?
MySQL uses the OpenSSL algorithm internally, using EVP_BytesToKey as the derivation function. Look at this URL
MySQL encryption and decryption example:
There is a JAR that supports this EVP_BytesToKey key derivation function.
}
This finally achieves interoperability! Hope this helps someone trying to do the same thing.