Answer the question
In order to leave comments, you need to log in
How to get same mcrypt encryption results in php and in console?
There is a standard implementation of encryption with mcrypt in php (DES with ECB mod):
var_dump(base64_encode(mcrypt_encrypt('des', 'abcd1234', 12345, 'ecb')));
string(12) "TkXoGeZK44Y="
mcrypt -a des -m ecb -b -q -F -k 'abcd1234' | base64
JWzYLaNSAOc=
or L0BJcpSopZU=
, depending on whether I do a line break before Ctrl+D. Answer the question
In order to leave comments, you need to log in
> depending on whether I am doing a line break before Ctrl+D.
The line break is quite a character, so it gets into the data from which the hash is calculated.
Pass through sed 's/^$//g' , for example.
Can solve the problem "on the forehead":
$ php -r "echo base64_encode(mcrypt_encrypt('des', 'abcd1234', '12345', 'ecb'));"
TkXoGeZK44Y=
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question