예제 #1
0
파일: b58.py 프로젝트: mebagger/pycoin-1
def b58(args, parser):
    for arg in args.input:
        blob, is_hex_input = parse_arg(arg, args.b)

        if is_hex_input:
            print(b2h(blob))
            print(b2a_base58(blob))
            print(b2a_hashed_base58(blob))
        else:
            print(b2h(blob))
            print(b2a_base58(blob))
            try:
                blob = a2b_hashed_base58(arg)
                print("valid hashed b58")
                print("contents: ", b2h(blob))
            except Exception:
                print("not hashed b58")
예제 #2
0
파일: b58.py 프로젝트: alanxu89/pycoin
def b58(args, parser):
    for arg in args.input:
        blob, is_hex_input = parse_arg(arg, args.b)

        if is_hex_input:
            print(b2h(blob))
            print(b2a_base58(blob))
            print(b2a_hashed_base58(blob))
        else:
            print(b2h(blob))
            print(b2a_base58(blob))
            try:
                blob = a2b_hashed_base58(arg)
                print("valid hashed b58")
                print("contents: ", b2h(blob))
            except Exception:
                print("not hashed b58")
예제 #3
0
def get_token(_: Request, resp: Response) -> None:
    raw_token = secrets.token_bytes(64)
    token = b58.b2a_base58(raw_token)
    hashed_token = sha256d(raw_token)
    created_at = int(time.time())
    result = {"code": "Success", "token": token}

    try:
        token_db.put(hashed_token, TokenDBData(created_at))
    except Exception as e:
        result = {"code": "Failed", "token": None, "error": str(e)}

    resp.media = result
예제 #4
0
 def do_test(as_text, as_bin):
     self.assertEqual(as_bin, a2b_base58(as_text))
     self.assertEqual(as_text, b2a_base58(as_bin))
예제 #5
0
def b2a_hashed_base58_grs(data):
    return b2a_base58(data + groestlHash(data)[:4])
예제 #6
0
 def do_test(as_text, as_bin):
     self.assertEqual(as_bin, a2b_base58(as_text))
     self.assertEqual(as_text, b2a_base58(as_bin))
예제 #7
0
 def _create_base58_with_checksum(cls, data):
     checksum = CoinKey._double_sha256(data)[:8]
     return_data = data + checksum
     return_data = b58.b2a_base58(binascii.unhexlify(return_data))
     return return_data