Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

php mcrypt_encrypt to C/C++/MFC equalivilent

Avatar of Chipkin_com
Chipkin_com asked on
CEditors IDEs
5 Comments1 Solution1066 ViewsLast Modified:
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

// 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 CERTIFIED SOLUTION
Avatar of CSecurity
CSecurityFlag of Iran, Islamic Republic of image

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

Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answers