1. 程式人生 > >加密方式

加密方式

pda pri enc md5 input .sh date usr ash

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: _wapn
import hashlib
import hmac

# md5加密
hash2 = hashlib.md5()
hash2.update(‘123456‘.encode(‘Utf-8‘))
print(hash2.hexdigest())

# sha系列加密
hash1 = hashlib.sha256()
hash1.update(‘123456‘.encode(‘utf-8‘))
print(hash1.hexdigest())

# hmac加密,hmac內部對創建的key和內容進行處理後再加密
h = hmac.new(‘加密‘.encode(‘utf-8‘))
h.update(input(‘>>>:‘).encode(‘utf-8‘))
print(h.hexdigest())

加密方式