php - MCrypt Inconsistent Between Servers When Decrypting -


i have below class 2 mcrypt methods. encrypting string, sending via jsonp through api , having consumer use same decrypt method same salt , not able decrypt string. test on server can ran in terms of encrypting , decrypting on same server, when encrypted string encrypted on 1 server , attempted decrypted on server using correct salt cannot decrypt it. mode (mcrypt_mode_ecb) understanding iv not necessary. have idea why happening?

<?php  class mcrypthelper {     /**      * encrypt      * encrypts string using mcrypt_rijndael_256 cipher , mcrypt_mode_ecb.      *      * @static      * @param string $string      * @param string $salt      * @return string      */     public static function encrypt($string, $salt)     {         $saltsize = mcrypt_get_key_size(mcrypt_rijndael_256, mcrypt_mode_ecb);         $salt = substr($salt, 0, $saltsize);         $ciphertext = mcrypt_encrypt(mcrypt_rijndael_256, $salt, $string, mcrypt_mode_ecb);         $encrypted = base64_encode($ciphertext);          return trim($encrypted);     }      /**      * decrypt      * decrypts string using mcrypt_rijndael_256 cipher , mcrypt_mode_ecb mode.      *      * @static      * @param string $string      * @param string $salt      * @return string      */     public static function decrypt($string, $salt)     {         $saltsize = mcrypt_get_key_size(mcrypt_rijndael_256, mcrypt_mode_ecb);         $salt = substr($salt, 0, $saltsize);         $ciphertext = base64_decode($string);         $decrypted = mcrypt_decrypt(mcrypt_rijndael_256, $salt, $ciphertext, mcrypt_mode_ecb);          return trim($decrypted);     } } 


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -