为什么PHP的md5与OpenSSL的md5不同? [英] Why PHP's md5 is different from OpenSSL's md5?

查看:218
本文介绍了为什么PHP的md5与OpenSSL的md5不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于为什么我在PHP和OpenSSL中看到md5散列的结果有所不同,我感到很困惑.

I am quite confused as to why I am seeing different results for md5 hashing in PHP and in OpenSSL.

这是我正在运行的代码:

Here is the code that I am running:

php -r "echo md5('abc');"

结果为:900150983cd24fb0d6963f7d28e17f72

Results in: 900150983cd24fb0d6963f7d28e17f72

与此同时:

echo abc | openssl md5

结果为:0bee89b07a248e27c83fc3d5951213c1

Results in: 0bee89b07a248e27c83fc3d5951213c1

为什么?

推荐答案

只有一种方法可以计算MD5.

There is only one way to compute MD5.

一个盲目的猜测是第二个字符串还在被散列的字符串中包含换行符.

A blind guess is that the second one also includes a newline inside the string being hashed.

是的,验证了它.就是这样.

Yeh, verified it. That's it.

这篇关于为什么PHP的md5与OpenSSL的md5不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆