Skip to content
Advertisement

Decrypting coldfusion encrypted string in PHP

I have a string encrypted in Coldfusion which needs to be decrypted in PHP for usage.

So i am looking for a method which corresponds to:

Decrypt(stringToDecrypt,"2450RDSET0C","CFMX_COMPAT","HEX")

Here,

stringToDecrypt = the string to be decrypted,

"2450RDSET0C" = the seed that was used to encrypt the string

CFMX_COMPAT = encryption algorithm

HEX = encoding used

https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/Decrypt.html

example string to be decrypted: 6A968A969DEB9A16549C61EE2EFE40A6515E

Advertisement

Answer

I was able to use the following code to decrypt your example string.

<?php
require __DIR__ . '/vendor/autoload.php';

use AwkwardIdeasPHPCFEncryptEncrypt;

$stringToDecrypt = '6A968A969DEB9A16549C61EE2EFE40A6515E';
$key = '2450RDSET0C';
$decrypted = Encrypt::decrypt($stringToDecrypt, $key, 'CFMX_COMPAT', 'hex');
var_dump($decrypted);
$ php main.php
string(18) "SofortUeberweisung"

After installing the dependency with composer.

composer require awkwardideas/phpcfencrypt

Here’s a GitHub Gist you can use to test with.

https://gist.github.com/AlexanderOMara/b9bb6ff2a57bd0cf61fa8f0823d9a2a0

Just run composer install first.

NOTE: This encryption scheme is rather weak!

Hopefully you are using this decryption code as part of a migration process to move to a stronger encryption scheme, like AES (or a password hash like bcrypt if this is for passwords).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement