mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
7cf9572c26
* Merge #11881: Remove Python2 support1874058
Make base58 python contrib code work with python3 (Evan Klitzke)bc6fdf2
Change all python files to use Python3 (John Newbery) Pull request description: Following discussion here: https://github.com/bitcoin/bitcoin/pull/11843#issuecomment-351033742 It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3. Tree-SHA512: 5d38eef6e0fc7d8515e23a1f4c75e8b4160fd0fe23cba52a1f41689b114e54a9e503e0724829e8b41982ef98f2d113df80d9e238213b74f09ceaed0344a19e24 * Merge #12829: Python3 fixupf50975b
[contrib] fixup symbol-check.py Python3 support (John Newbery)5de2b18
[contrib] fixup security-check.py Python3 support (John Newbery) Pull request description: security-check.py and symbol-check.py were broken by #11881. Fix them. Tree-SHA512: 86de3d6dc3292b1ae4cc04c2d7d7dbbf39c9270551d7b224b8d8b19e3184c30c897dbf823200403706d06bb405c0decad5cfd690cb2c0312992a235a4ffcf6bf
42 lines
1.1 KiB
Python
Executable File
42 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2015 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
import hashlib
|
|
import sys
|
|
import os
|
|
from random import SystemRandom
|
|
import base64
|
|
import hmac
|
|
|
|
if len(sys.argv) < 2:
|
|
sys.stderr.write('Please include username as an argument.\n')
|
|
sys.exit(0)
|
|
|
|
username = sys.argv[1]
|
|
|
|
#This uses os.urandom() underneath
|
|
cryptogen = SystemRandom()
|
|
|
|
#Create 16 byte hex salt
|
|
salt_sequence = [cryptogen.randrange(256) for i in range(16)]
|
|
hexseq = list(map(hex, salt_sequence))
|
|
salt = "".join([x[2:] for x in hexseq])
|
|
|
|
#Create 32 byte b64 password
|
|
password = base64.urlsafe_b64encode(os.urandom(32))
|
|
|
|
digestmod = hashlib.sha256
|
|
|
|
if sys.version_info.major >= 3:
|
|
password = password.decode('utf-8')
|
|
digestmod = 'SHA256'
|
|
|
|
m = hmac.new(bytearray(salt, 'utf-8'), bytearray(password, 'utf-8'), digestmod)
|
|
result = m.hexdigest()
|
|
|
|
print("String to be appended to bitcoin.conf:")
|
|
print("rpcauth="+username+":"+salt+"$"+result)
|
|
print("Your password:\n"+password)
|