计算字符串的MD5哈希值
<?php
function renewCode( $schoolName, $certId, $barcode, $indate ){
return strtoupper( substr( md5( $schoolName.$certId.$barcode.$indate ), 3, 8 ) );
}
?>
I don't understand the function of MD5()。I mean I know the school Name and all of data but I can not get the right return like that
我不明白MD5()的功能。我的意思是我知道学校名称和所有数据,但我无法得到正确的回报
For example:
the right return: 19B55890
正确的回报:19B55890
Md5 encryption that string "xxxxxxxx.xxxxxxxxx.01187422.2013-03-20
"
字符串“xxxxxxxx.xxxxxxxxx.01187422.2013-03-20”的Md5加密
CBBDFC8D228B7FCFECCFC54FBB3C9D87
it's did not equal 19B55890
它不等于19B55890
1 个解决方案
#1
$schoolName.$certId.$barcode.$indate
does not have .
chars in the output - that's the concatenate operator. That input gives a string of:
$ schoolName。$ certId。$ barcode。$ indate没有。输出中的字符 - 这是连接运算符。该输入给出了一串:
大连民族学院图书馆2012081507011874222013-03-20
which when hashed, gives:
当哈希时,给出:
a6019b5589029bf9378cfff4c631fc7d
The substring 3,8 of which is:
子串3,8是:
19b55890
Also note that MD5 is not encryption, it's a one way hash of the input string. It's also considered fairly insecure now; it's recommended to use SHA-256 based hashes if you're able to switch.
另请注意,MD5不是加密,它是输入字符串的单向散列。它现在也被认为是相当不安全的;如果你能够切换,建议使用基于SHA-256的哈希。
更多相关文章
- 在两个不同的地方分割/爆炸一个PHP字符串
- PHP中的嵌套(多个)字符串插值
- 查找具有特定数据字符串的数组并返回其具有的另一个数据字符串
- 在php中,从字符串中删除逗号后的所有内容
- 如何通过PHP将HTML页面作为字符串获取?
- php 基本的常用字符串函数
- 用PHP计算字符串中元音的简单方法?
- 将DOMDocument中的特定元素导出为字符串
- PHP实现字符串转换成查询语句