python数据加密代码
                        
                            时间:2021-07-01 10:21:17
                            帮助过:42人阅读
							                        
                     
                    
                    1、hashlib 
import hashlib 
#创建一个哈希对象 
md = hashlib.md5() 
#md = hashlib.sha1() 
#md = hashlib.sha224() 
#md = hashlib.sha25() 
#md = hashlib.sha384() 
#md = hashlib.sha512() 
1.1 hashlib.update(arg) 
1.2 hashlib.digest() #返回数字形式的哈希 
1.3 hashlib.hexdigest() #返回16进制的哈希 
1.4 hashlib.copy() 
一般而言,用hashlib.hexdigest()就可以了 
2、hmac 
2.1 hmac.new(key[, msg[, digestmod]]) 
2.2 hmac.update(msg) 
2.3 hmac.digest() 
2.4 hmac.hexdigest() 
2.5 hmac.copy() 
要注意,上面的message都要用bytes,使用string不可以