9 from random
import SystemRandom
14 sys.stderr.write(
'Please include username as an argument.\n')
17 username = sys.argv[1]
20 cryptogen = SystemRandom()
23 salt_sequence = [cryptogen.randrange(256)
for i
in range(16)]
24 hexseq = list(map(hex, salt_sequence))
25 salt =
"".join([x[2:]
for x
in hexseq])
28 password = base64.urlsafe_b64encode(os.urandom(32))
30 digestmod = hashlib.sha256
32 if sys.version_info.major >= 3:
33 password = password.decode(
'utf-8')
36 m = hmac.new(bytearray(salt,
'utf-8'), bytearray(password,
'utf-8'), digestmod)
37 result = m.hexdigest()
39 print(
"String to be appended to bitcoin.conf:")
40 print(
"rpcauth="+username+
":"+salt+
"$"+result)
41 print(
"Your password:\n"+password)