Пример #1
0
def is_minikey(text):
    # Minikeys are typically 22 or 30 characters, but this routine
    # permits any length of 20 or more provided the minikey is valid.
    # A valid minikey must begin with an 'S', be in base58, and when
    # suffixed with '?' have its SHA256 hash begin with a zero byte.
    # They are widely used in Casascius physical bitoins.
    return (len(text) >= 20 and text[0] == 'S'
            and all(c in __b58chars for c in text)
            and ord(sha256(text + '?')[0]) == 0)
Пример #2
0
 def get_bytes(self, n):
     while len(self.pool) < n:
         self.pool.extend(self.sha)
         self.sha = sha256(self.sha)
     result, self.pool = self.pool[:n], self.pool[n:]
     return result
Пример #3
0
 def __init__(self, seed):
     self.sha = sha256(seed)
     self.pool = bytearray()
Пример #4
0
def minikey_to_private_key(text):
    return sha256(text)
Пример #5
0
 def test_create_txid(self):
     _tx_sha256 = sha256(sha256(raw_tx.decode('hex')))
     _tx_hex = _tx_sha256[::-1].encode('hex')
     self.assertEqual(_tx_hex, tx_id)