开发者

different results for openssl base64 and PHP base64_encode

I am trying to base64 encode a string in PHP and openssl.

openssl: echo -n "1234567890A" | openssl enc -base64

php:

$hash = sha1("1234567890A", true);
开发者_StackOverflowvar_dump($hash);
echo base64_encode($hash);

the results differ:

openssl: MTIzNDU2Nzg5MEE=

PHP: /Q6nenquhGpX5h2WdiQZQF47Pe8=

I guess this is just a simple setting I can use to adapt result 1 or 2, since PHP produces a string of exact the double size of string 1.

Please help me out. Many thanks, Ron


Why are you taking SHA1 hash of it? Just do this:

 echo base64_encode("1234567890A");

 // Output: MTIzNDU2Nzg5MEE=
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜