python中hashlib md5
阿新 • • 發佈:2018-01-09
sharp lib class log time() div time enc csharp
如下兩種方法,結果相同
import hashlib import time m = hashlib.md5() m.update(str(time.time()).encode(‘utf-8‘)) print(m.hexdigest()) m2 = hashlib.md5(str(time.time()).encode(‘utf-8‘)) print(m2.hexdigest()) # ad8720ac04abb38e20d79093b18505c1 # ad8720ac04abb38e20d79093b18505c1
或
import hashlib import time m = hashlib.md5() m.update(str(time.time()).encode(‘utf-8‘)) m.update(‘lcg‘.encode(‘utf-8‘)) print(m.hexdigest()) m2 = hashlib.md5((str(time.time())+‘lcg‘).encode(‘utf-8‘)) print(m2.hexdigest()) # 0f1bd01d97cd41525cd79b27b6e0b5ba # 0f1bd01d97cd41525cd79b27b6e0b5ba
python中hashlib md5