C / C + + / MFC equalivilent php MCRYPT_ENCRYPT

2 Cevap php

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

Ben C + + / MFC yukarıdaki fonksiyonun çıkışı çözümlenmiş bir yol arıyorum.

2 Cevap

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

Yardımlarınız için teşekkürler @ vartec

libmcrypt aslında bir C kütüphanesi