js中pbkdf2_hmac加密python翻译java中的pbkdf2_hmac加密和解码代码⽚段,使⽤python翻译
import hashlib
import base64
import hmac
import binascii
avilible意思import json
import re
from Crypto.Cipher import AES
from binascii import a2b_hex
# url加密代码
"""
f = o.default.HmacSHA1(Utf8.parse(f), "D23ABC@#56"),
f = Base64.stringify(f).toString(),
之后进⾏md5编码
"""
def hash_hmac(txt, key='D23ABC@#56', sha1=hashlib.sha1):
hmac_code = de(), de(), sha1).digest()
md5 = hashlib.md5()
md5.update(base64.b64encode(hmac_code))
return md5.hexdigest()
# api接⼝返回数据js加密代码
"""
a = o.default.PBKDF2(f, "secret", {
keySize: 8, # 输出64位
iterations: 1e3,
hasher: o.default.algo.SHA256
}).toString()
u = o.default.PBKDF2(h, "secret", {
keySize: 4, # 输出32位
iterations: 1e3,
hasher: o.default.algo.SHA256
使用python数据分析}).toString();
o.pt(Utf8.parse(l), Hex.parse(a), {
iv: Hex.parse(u)
}).toString()
"""
#翻译代码
def decrypt(text):
n = hashlib.pbkdf2_hmac(hash_name='sha256',
python基础代码大全加翻译password=b'D23ABC@#56',
salt=b'secret',
iterations=1000)
key = binascii.hexlify(n)
h = hashlib.pbkdf2_hmac(hash_name='sha256',
password=b'apidata/api/gk/score/special',
transfer point incsalt=b'secret',
iterations=1000)
iv = binascii.hexlify(h)[:32]js event事件
mode = AES.MODE_CBC
cryptos = w(a2b_hex(key), mode, a2b_hex(iv))网站设计用什么软件好
plain_text = cryptos.decrypt(a2b_hex(text))
return json.loads(re.findall('(\{.*\})',bytes.decode(plain_text))[0])
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论