I have data encrypted in ColdFusion that I should be able to decrypt and encrypt the exact same value using Java. I was hoping someone could help me. I will indicate everything that is used in ColdFusion, except for the actual PasswordKey, which I have to keep secret for security purposes. Password length is 23 characters. It uses uppercase and lowercase letters, numbers and + and = signs. I know this is a lot to ask, but any help would be greatly appreciated.
I tried using the Java encryption example, which I found online and simply replaced the line below 23 characters used in our CF application:
private static final byte[] keyValue = new byte[] {'T', 'h', 'i', 's', 'I', 's', 'A', 'S', 'e', 'c', 'r', 'e', 't', 'K', 'e', 'y' };`
But I get the error:
java.security.InvalidKeyException: Invalid AES key length: 23 bytes
CF Code:
Application.PasswordKey = "***********************"; Application.Algorithm = "AES"; Application.Encoding = "hex"; <cffunction name="encryptValue" access="public" returntype="string"> <cfargument name="strEncryptThis" required="yes"> <cfreturn Encrypt(TRIM(strEncryptThis), Application.PasswordKey, Application.Algorithm, Application.Encoding)> </cffunction> <cffunction name="decryptValue" access="public" returntype="string"> <cfargument name="strDecryptThis" required="yes"> <cfreturn Decrypt(TRIM(strDecryptThis), Application.PasswordKey, Application.Algorithm, Application.Encoding)> </cffunction>
source share