python md5 signature

   python comes hashlib library can handle md5 signature.

   import  hashlib

md5sign DEF (filename): 
with Open (filename, "R & lt") AS F:
the try:
fmd5 = hashlib.md5 (reached, f.read () encode ( "UTF-. 8").) reached, f.read ## () read out unicode data is encoded format, and
# Hashlib.md5 not recognize this format, it is necessary to perform encoding format, such as utf-8, gb2312 like 

return fmd5.hexdigest () ## returns the signature file
the except Exception AS E:
logger.info ( "% S = error", the repr (E))

Guess you like

Origin www.cnblogs.com/huanhuaqingfeng/p/11130588.html