How to get MD5 sum of a string using python?

后端 未结 6 1245
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 09:07

In the Flickr API docs, you need to find the MD5 sum of a string to generate the [api_sig] value.

How does one go about generating an MD5 sum from a str

6条回答
  •  醉话见心
    2020-11-27 10:03

    You can use b character in front of a string literal:

    import hashlib
    print(hashlib.md5(b"Hello MD5").hexdigest())
    print(hashlib.md5("Hello MD5".encode('utf-8')).hexdigest())
    

    Out:

    e5dadf6524624f79c3127e247f04b548
    e5dadf6524624f79c3127e247f04b548
    

提交回复
热议问题