php rsa encryption function returning nothing -


i using phpseclib rsa encryption http://phpseclib.sourceforge.net/.

this php code:

include('math/biginteger.php'); include('crypt/rsa.php');   $message="123456"; $private_modulus = "272435f22706fa96de26e980d22dff67"; $private_exponent = "158753ff2af4d1e5bbab574d5ae6b54d";  $rsa = new crypt_rsa();  $message = new math_biginteger(base64_decode($message), 256); $private_modulus = new math_biginteger(base64_decode($private_modulus), 256); $private_exponent = new math_biginteger(base64_decode($private_exponent), 256);   $rsa->loadkey(array('n' => $private_modulus, 'e' => $private_exponent)); $encryptedtext=$rsa->encrypt($message); echo  $encryptedtext; 

however, encryptedtext blank. help?

you have issues public/private keys. of function $rsa->loadkey() comment, first parameter string, have assigned strange array...

/**  * loads public or private key  *  * returns true on success , false on failure (ie. incorrect password provided or key malformed)  *  * @access public  * @param string $key  * @param integer $type optional  */ function loadkey($key, $type = false) 

example of working encrypt/decrypt random public/private keys :

include('_seclib/math/biginteger.php'); include('_seclib/crypt/rsa.php');  $rsa = new crypt_rsa(); extract($rsa->createkey());  # encrypt $message = '123456'; $rsa->loadkey($publickey); $ciphertext = $rsa->encrypt($message); var_dump($ciphertext);  # decrypt $rsa->loadkey($privatekey); var_dump($rsa->decrypt($ciphertext)); 

see documentation more info.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -