Chipkin_com
asked on
php mcrypt_encrypt to C/C++/MFC equalivilent
Hello
I have a PHP script that generates a product key for an application written in c++/MFC. The product key is email to the user and the user copy and pasts it in to my application.
I'm looking for a way to decoded the output of the php function in C++/MFC.
I have looked in to http://mcrypt.sourceforge.net/ but its too advanced for me
I have a PHP script that generates a product key for an application written in c++/MFC. The product key is email to the user and the user copy and pasts it in to my application.
I'm looking for a way to decoded the output of the php function in C++/MFC.
I have looked in to http://mcrypt.sourceforge.net/ but its too advanced for me
// PHP code
function EncryptData( $data ) {
$key = "abcdefghijklmnopqrstuvwxyz";
// This encrypt method is described here
// http://ca3.php.net/mcrypt
$val = $data ;
$ky = $key ;
$mode = MCRYPT_MODE_ECB;
$enc = MCRYPT_RIJNDAEL_128;
$val = str_pad($val, (16*(floor(strlen($val) / 16)+(strlen($val) % 16==0?2:1))), chr(16-(strlen($val) % 16)));
$encript = mcrypt_encrypt($enc, $ky, $val, $mode, mcrypt_create_iv( mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM));
$hex = bin2hex( $encript ) ;
$ret = strtoupper( $hex );
return $ret; }
ASKER
Uhm no.
Why would I encrypt it in the first place if I'm then going to turn around a send it plain text (over the wire) once the user receives it. I don't want the users to know what is inside the encrypted data.
I was hoping not to have to code the function myself.
I'm surprised that this hasn't been done before unless everyone is using the http://mcrypt.sourceforge.net/ library and that seems unlikely.
Why would I encrypt it in the first place if I'm then going to turn around a send it plain text (over the wire) once the user receives it. I don't want the users to know what is inside the encrypted data.
I was hoping not to have to code the function myself.
I'm surprised that this hasn't been done before unless everyone is using the http://mcrypt.sourceforge.net/ library and that seems unlikely.
ASKER
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
oh! sorry, forgot to tell
RC4 is some nice algorithm because encryption and decryption algorithms are the same. lemme make it more clear. if you encrypt some data using rc4 algorithm using some password and then want to decrypt it, you should decrypt it as if you want encrypt it.
regards
RC4 is some nice algorithm because encryption and decryption algorithms are the same. lemme make it more clear. if you encrypt some data using rc4 algorithm using some password and then want to decrypt it, you should decrypt it as if you want encrypt it.
regards
so, i suggest you write a php page that gives some parameters (data) and then takes the result. so, your MFC application can send data using HTTP POST method to send encrypted data and your php should give back decoded data to MFC data.
yours sincerely