encodes a base58 string to as a big endian integer
(s)
| 1937 | |
| 1938 | @staticmethod |
| 1939 | def base58_to_binary(s): |
| 1940 | """encodes a base58 string to as a big endian integer""" |
| 1941 | if Exchange.base58_decoder is None: |
| 1942 | Exchange.base58_decoder = {} |
| 1943 | Exchange.base58_encoder = {} |
| 1944 | for i, c in enumerate(Exchange.base58_alphabet): |
| 1945 | Exchange.base58_decoder[c] = i |
| 1946 | Exchange.base58_encoder[i] = c |
| 1947 | result = 0 |
| 1948 | for i in range(len(s)): |
| 1949 | result *= 58 |
| 1950 | result += Exchange.base58_decoder[s[i]] |
| 1951 | return result.to_bytes((result.bit_length() + 7) // 8, 'big') |
| 1952 | |
| 1953 | @staticmethod |
| 1954 | def binary_to_base58(b): |