Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

Non-base32 digit found

import hmac
import base64
import hashlib
import datetime
import time


#totp
interval=30 #seconds


#otp
digest=hashlib.sha1
digits=6 #number of integers supported?
secret='123456789abcdefg'



#totp
now=datetime.datetime.now()
i=time.mktime(now.timetuple())
timecode=int(i/interval)


#otp
base64_secret = base64.b32decode(secret,casefold=True)
res = []
while timecode != 0:
    res.append(chr(timecode & 0xFF))
    timecode = timecode >> 8
bytestring=''.join(reversed(res)).rjust(8,'') #padding=8
hmac_hash = hmac.new(
    base64_secret,
    bytestring,
    digest
).digest()

offset=ord(hmac_hash[19]) & 0xf
code = ((ord(hmac_hash[offset]) & 0x7f) << 24 |
    (ord(hmac_hash[offset + 1]) & 0xff) << 16 |
    (ord(hmac_hash[offset + 2]) & 0xff) << 8  |
    (ord(hmac_hash[offset + 3]) & 0xff))

code = code % 10 ** digits

print (code)
Comment

PREVIOUS NEXT
Code Example
Shell :: pass bash variable to grep 
Shell :: how to remove git ssh from macbook 
Shell :: set dynamic values with kubernetes yaml file 
Shell :: eval assignment 
Shell :: Brave Beta on OpenSUSE 15+ 
Shell :: restart service hpux 
Shell :: Ubuntu Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 15551 (apt) 
Shell :: docker php fpm xsl 
Shell :: mark raid drive as faulty linux 
Shell :: cara lihat password mac 
Shell :: This script uses variables to make a backup of my home directory. 
Shell :: what is vagrant and system requirements 
Shell :: |select name and description powershell 
Shell :: How would you make changes to a repository on GitHub inside a bash terminal? 
Shell :: update aur packages archlinux 
Shell :: install psalm laravel 
Shell :: mercurial remove missing files 
Shell :: centos run command in background 
Shell :: how to extract sequential files multiple zip files at once 
Shell :: find powershell profiles linux 
Shell :: Delay app startup on Ubuntu 
Shell :: how to download github code in terminal 
Shell :: how to uninstall in ubuntu 
Shell :: bash how to create directories in all subdirectories 
Shell :: bash $! command 
Shell :: remove folders from remote git 
Shell :: run artisan queue --once loop 
Shell :: nano duplicate line or copy paste line 
Shell :: reinstall all tables doctrine 
Shell :: annullare i cambiamenti git 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =