troubleshooting Question

php mcrypt_encrypt to C/C++/MFC equalivilent

Avatar of Chipkin_com
Chipkin_com asked on
Editors IDEsC
5 Comments1 Solution1066 ViewsLast Modified:
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 but its too advanced for me

// PHP code 
function EncryptData( $data ) {
$key  = "abcdefghijklmnopqrstuvwxyz";
// This encrypt method is described here 
$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; }

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros