0

Hello, does anybody know why below 2 echoes are providing diferent results

<?php
   $in ='textInputTest'; $key ='AAAABBBBAAAABBBB'; $iv ='AAAABBBB';
   echo base64_encode(mcrypt_encrypt(MCRYPT_RC2, $key, $in, MCRYPT_MODE_CBC, $iv)) .":";
   echo base64_encode(openssl_encrypt($in, 'rc2-cbc', $key, true, $iv));
?>

(results: I6twEgBKQEaNzeP0nMeLJg== : 7bJWXaOJf31WYcJn2UcDrg==)
...
second result is the same that C# and some other tools provides. So OpenSSL conform my needs... But I still want to know why MCRYPT result is different because the same encryption mode, cypher, key and init-vector used...

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by omer.merdan
0

Well, 16 plain ascii characters inside $key string should be exactly 128bits binary, and initialisation vector $iv 8asciichars =8bytes =64bit for rc2. Comparing to other php examples about encrypting, this is ok. Intention was rc2-128bit-cbc.

- Openssl library for php behaves exactly as supossed (compared to other languages tests) ... but sometimes there will be situation on some server where openssl is disabled... and i am wondering if MCRYPT functions are also good or unreliable.

Edited by omer.merdan: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.