Search code examples
coldfusioncoldfusion-9coldfusion-10

Encrypt & Decrypt credit card using coldfusion?


Is there any way to encrypt & decrypt credit card details with custom key using ColdFusion?

I have tried with JAVA file (Should i post the code?).

there is the code in which am getting error.

<cfdump var="#CreateObject('JAVA','StrongAES')#"><cfabort>

I am getting Server Error 500

Thanks


Solution

  • You can use encrypt and decrypt methods to perform encryption and decryption. You can either user generate secret key or use your custom key to do that. Here is what i will do.

    <!--- To generate secret key (you can also use your custom key) --->
    <cfset secretKey = generateSecretKey("AES") />
    
    <!--- to encrypt --->
    <cfset encryptedDetails = encrypt(cardDetails, secretKey , "AES/CBC/PKCS5Padding", "HEX") />
    
    <!--- to decrypt --->
    
    <cfset cardDetails= decrypt(encryptedDetails , secretKey , "AES/CBC/PKCS5Padding", "HEX") />
    

    For more details see Encrypt and decrypt