计算字符串的MD5哈希值

时间:2022-10-28 18:15:55
<?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的哈希。

#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的哈希。