views:

293

answers:

3

Hello. I'm not english speaker, sorry in advance.

I have a ColdFusion 6.1 application, and now I'm trying to migrate to another enviroment. In the ColdFusion application the passwords of my users are crypted with a ColdFusion function:

password_encrypted=toBase64(encrypt(text,key));

any one knows how can I decrypt it in PHP? I don't know whats the cypher algorithm used in CFMX 6.1... I think that the name of the algorithm is CFMX_COMPAT, but I don't know if it has an equivalent in php.

Thanks!!!

+1  A: 

Maybe a dumb question, why not try UN-encrypting using Coldfusion 6? Insert that into the record as plain text (while in DEV).

Then encrypt with any format you want using PHP. That way you are 100% sure it will be decrypted/understood from Coldfusion to PHP.

As reference here is the CF 6 encrypt() fn: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt175.htm

and here is decrypt() fn: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt170.htm#1103962

Jakub
Smart answer....what i was thinking too lol
crosenblum
A: 

So you have the encrypted passwords and want to retrieve them in plain text? If that's the case, I don't think it's viable. In fact passwords are encrypted to prevent people from doing exactly that.

Mij
Look at his example, `toBase64(encrypt(text,key));` ... that is not a one way hash.
Tim Post
+4  A: 

If I'm not mistaken, the default CFMX_COMPAT function is simply a XOR.

So in PHP this would be as simple as:

$password_encrypted = base64_encode($text ^ $key);

Hope this helps.

Edit:

I was curious so I wrote a little script to test, and this might be reversed, here is the encrypt/decrypt.

<?php

$text = 'test';
$key = 'asdf';

$password_encrypted = base64_encode($key ^ $text);

echo $password_encrypted . "<br>\n";

$password_decrypted = base64_decode($password_encrypted) ^ $key;

echo $password_decrypted;

?>
evolve
As you can see, bitwise operators are not my strong point.
evolve
Thanks Evolve. Your answer is probably correct, but it not works in my problem. I can't do it, but thank you very much. I will try decrypt all the passwords with ColdFusion and store them in my DB.
Carlos