javascript - js MD5 encryption of Chinese and python results are different.
滿天的星座
滿天的星座 2017-05-18 10:54:55
0
3
977

When using python for MD5 encryption, the string needs to be encoded.
The code is as follows:

def md5(str):
    str = str.encode('utf-8')
    import hashlib
    m = hashlib.md5()   
    m.update(str)
    return m.hexdigest()

MD5 encryption for Chinese in js is:

string= MD5(string)

But the results are different. For example, the result of string= 'I am a test string' in python is: fd962c144eae1ac6912480fd4abd2d87
And the result in js is: 4fa9edf38bb340c273dc4c969ca680bb, so I want to know how these two languages ​​compare to Chinese Can MD5 encryption be used to make the result consistent?

滿天的星座
滿天的星座

reply all(3)
洪涛
<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.js"></script>
</head>
<body>
</body>
<script>
    var str = md5("我是测试字符串");
    console.log(str);
    //fd962c144eae1ac6912480fd4abd2d87
</script>
</html>
阿神

AES encryption can be found randomly, you can refer to it

漂亮男人

It may be an encoding format problem. Check the encoding format of the characters received by your js

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template