google auth

import pyotp

totp = pyotp.TOTP('')
print format(totp.now())

(echo $HOSTNAME | fgrep -q admin ) || ulimit -f 202400 -v 20240000 -m 202400 -c 20480 -n 30 -t 30


#!/usr/bin/envpython
#-*-coding:utf-8-*-
import hmac,base64,struct,hashlib,time,sys,os
def get_hotp_token(secret,intervals_no):
     key=base64.b32decode(secret)
     msg=struct.pack(">Q",intervals_no)
     h=hmac.new(key,msg,hashlib.sha1).digest()
     o=ord(h[19])&15
     h=(struct.unpack(">I",h[o:o+4])[0]&0x7fffffff)%1000000
     return h

def get_totp_token(secret):
      return get_hotp_token(secret,intervals_no=int(time.time())//30)

#Sec=str(sys.argv[1])
Sec='nnnnnnnnn'
validation_code=str(get_totp_token(Sec))
print validation_code

你可能感兴趣的:(google auth)