生成otp token 脚本
作者:互联网
#!/usr/bin/python3
import re
import time
import hashlib
import struct
import base64
import hmac
from random import choice
from string import ascii_letters, digits
from sys import argv
secret = '这里是你的secret'
mangling_string = 'ASGIw3gQMAbEw6z4u8xxmfwYx5qG4b16'
def get_hotp_token(secret, intervals_no): key = base64.b32decode(secret, True) msg = struct.pack(">Q", intervals_no) h = hmac.new(key, msg, hashlib.sha1).digest() o = h[19] & 15 h = (struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000 return h
try: token = get_totp_token(xor_crypt_string( secret, mangling_string, decode=True)) except: print("Invalid Secret")
token = '123456' + '%06d' % token print(token)
标签:脚本,int,secret,token,key,otp,import,data 来源: https://www.cnblogs.com/sweetsunnyflower/p/14339847.html