KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
currently we have a mcrypt implentation on our systems to crypt some sensible data in our PHP application. Now we have a new requirement that we have to change the crypt module to openssl. Another thing which is important know is that we are using the cipher blowfish and the mode ecb. So I began to test what are differences and how I can decrypt mcrypt encrypted strings with openssl. I used the standard PHP function: mcrypt_encrypt vs. openssl_encrypt mcrypt_decrypt vs. openssl_decrypt Both methods are delivering different results. Second thing is that in the given cipher (blowfish) and mode (ecb) in both types different IV lengthes are required (openssl=0 and mcrypt=56). Does anybody know how I can easily change the modules without having a big migration effort? Thanks in advance! UPDATE: Here is the code, which I tested it: <?php function say($message){ if(!is_string($message)){ if(!isset($_SERVER["HTTP_USER_AGENT"])) echo "<pre>"; echo var_export($message, true) . ((!isset($_SERVER["HTTP_USER_AGENT"]) ? "\n" : "<br />")); if(!isset($_SERVER["HTTP_USER_AGENT"])) echo "</pre>"; }else{ echo $message . ((!isset($_SERVER["HTTP_USER_AGENT"]) ? "\n" : "<br />")); } } say("= Begin raw encryption"); $key = "anotherpass"; $str = "does it work"; say(" Params:"); say(" - String to encrypt '".$str."'"); say(" - Key: ".$key); say(""); $params = array( "openssl" => array( "cipher" => "BF", "mode" => "ECB", ), "mcrypt" => array( "cipher" => "blowfish", "mode" => "ecb", ), ); say("= Mcrypt"); $handler = mcrypt_module_open($params['mcrypt']['cipher'], '', $params['mcrypt']['mode'], ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($handler), MCRYPT_RAND); $keysize = mcrypt_enc_get_key_size($handler); mcrypt_ge
Tags (comma-separated)
Save Edits
Cancel