views:

305

answers:

2

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.

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; }

I'm looking for a way to decoded the output of the above function in C++/MFC.

+2  A: 

libmcrypt is actually a C library

vartec
I took a look at libmcrypt, its a little over my head. I was hoping for something simpler.
Steven smethurst
A: 

I found a good article on code projects. It was pretty easy to set up and works great. http://www.codeproject.com/KB/security/aes.aspx

@vartec Thanks for your help

Steven smethurst