Decode a Base X encoded string into the number Arguments: - `string`: The encoded string - `alphabet`: The alphabet to use for encoding
(string, alphabet=ALPHABET)
| 36 | return ''.join(arr) |
| 37 | |
| 38 | def decodeBase58(string, alphabet=ALPHABET): |
| 39 | """Decode a Base X encoded string into the number |
| 40 | |
| 41 | Arguments: |
| 42 | - `string`: The encoded string |
| 43 | - `alphabet`: The alphabet to use for encoding |
| 44 | """ |
| 45 | base = len(alphabet) |
| 46 | num = 0 |
| 47 | |
| 48 | try: |
| 49 | for char in string: |
| 50 | num *= base |
| 51 | num += alphabet.index(char) |
| 52 | except: |
| 53 | #character not found (like a space character or a 0) |
| 54 | return 0 |
| 55 | return num |
| 56 | |
| 57 | def encodeVarint(integer): |
| 58 | if integer < 0: |