Base58 originates from bitcoin where the inventor Satoshi intentionally removes “iILloO0” which are confusing letters/digits when they appear in printing..
Base58 uses the following character set:
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
In Blockchain such as bitcoins or Tron, the public wallet address is computed from private keys (256 bit random bytes). The wallet address is a base58 string, and we can decode and check the checksum. The following is a Python command line tool that uses the base58 library to perform the b58decode_check for the addresses.
import base58
import sys
def address_hex(address):
arr = base58.b58decode_check(address).hex().lower()
s = []
for i in range(0, len(arr) - 1, 2):
s.append("0x" + arr[i] + arr[i + 1])
return "{" + ",".join(s) + "}"
if len(sys.argv) <= 1:
print("Usage: " + sys.argv[0] + " str1 str2 ...")
exit()
for i in sys.argv[1:]:
print(i)
print(address_hex(i))
For example:
$ python3 b58.py TFczxzPhnThNSqr5by8tvxsdCFRRz6cPNq TSSMHYeV2uE9qYH95DqyoCuNCzEL1NvU3S
TFczxzPhnThNSqr5by8tvxsdCFRRz6cPNq
{0x41,0x3d,0xfe,0x63,0x7b,0x2b,0x9a,0xe4,0x19,0x0a,0x45,0x8b,0x5f,0x3e,0xfc,0x19,0x69,0xaf,0xe2,0x78,0x19}
TSSMHYeV2uE9qYH95DqyoCuNCzEL1NvU3S
{0x41,0xb4,0xa4,0x28,0xab,0x70,0x92,0xc2,0xf1,0x39,0x5f,0x37,0x6c,0xe2,0x97,0x03,0x3b,0x3b,0xb4,0x46,0xc1}
Tron Blockchain
- How to Get Balance of TRX or USDT/USDD (TRC-20) Smart Contract Tokens on TRON Blockchain?
- Function to Return the USDT/USDD Contract Address on Tron Blockchain (Main Net, Nile, Shasta)
- How to Send/Transfer USDT on Tron Blockchain using Tronweb?
- Javascript Function to Send Trx on Tron Blockchain based on TronWeb
- How to Generate an Account on Tron Blockchain using Python SDK?
- How to Claim the Witness (Super Representative) Voting Rewards on Tron Blockchain using Node Js (Javascript)?
- Automate Freeze Balance on Tron Blockchain using NodeJs with TronWeb/TronGrid
- Python Tool of Base58 Decode Check
–EOF (The Ultimate Computing & Technology Blog) —
608 wordsLast Post: Teaching Kids Programming - Rotate a 2D Matrix/Image 90 Degree Clockwise
Next Post: GoLang: Check If N and Its Double Exist (Hash Map)
