1
dreamage OP |
2
wsy2220 2017-07-04 17:25:06 +08:00
没毛病,原文要先转成二进制
|
3
wsy2220 2017-07-04 17:25:43 +08:00
|
4
Kilerd 2017-07-04 18:16:56 +08:00
这是签名!!!!不是加密!!!!!!
|
8
dreamage OP @wsy2220 python 得不到想要的结果
import hashlib import hmac base = [str(x) for x in range(10)] + [ chr(x) for x in range(ord('A'),ord('A')+6)] #10->2 def dec2bin(string_num): num = int(string_num) mid = [] while True: if num == 0: break num,rem = divmod(num, 2) mid.append(base[rem]) return ''.join([str(x) for x in mid[::-1]]) #16->10 def hex2dec(string_num): return str(int(string_num.upper(), 16)) #16->2 def hex2bin(string_num): return dec2bin(hex2dec(string_num.upper())) key = "123456" msg = hex2bin('0015025c01000000001a1ecf006a0000') print msg m = hmac.new(key, msg, hashlib.sha1) signature = m.hexdigest() print signature ------------------------------- 101010000001001011100000000010000000000000000000000000000000000011010000111101100111100000000011010100000000000000000 29c6662533383f42db96fa6a7f82f265aa1b84e8 |
9
wsy2220 2017-07-05 12:17:40 +08:00
@dreamage python hex2bin 意思跟别的不一样,应该用下面这个:
import binascii hexstr = '0015025c01000000001a1ecf006a0000' binstr = binascii.unhexlify(hexstr) |
11
suduo1987 2017-07-25 16:47:17 +08:00
CryptoJS
|