check other errors : from os import urandom
from binascii import b2a_hex
from hashlib import sha1

def getTorPassHash(secret=‘password’):
‘’‘
https://gist.github.com/jamesacampbell/2f170fc17a328a638322078f42e04cbc
‘’’
# static ‘count’ value later referenced as “c”
indicator = chr(96)
# generate salt and append indicator value so that it
salt = “%s%s” % (urandom(8), indicator)
c = ord(salt[8])
# generate an even number that can be divided in subsequent sections. (Thanks Roman)
EXPBIAS = 6
count = (16+(c&15)) << ((c>>4) + EXPBIAS)
d = sha1()
# take the salt and append the password
tmp = salt[:8]+secret
# hash the salty password
slen = len(tmp)
while count:
if count > slen:
d.update(tmp)
count -= slen
else:
d.update(tmp[:count])
count = 0
hashed = d.digest()
# Put it all together into the proprietary Tor format.
return ‘16:%s%s%s’ % (b2a_hex(salt[:8]).upper(),
b2a_hex(indicator),
b2a_hex(hashed).upper())

if name == ‘main’:
print(getTorPassHash(raw_input("Type something: ")))