Sunday, January 02, 2022

base58 encode/decode: JavaScript, Go, C#

Binary-to-text encoding - Wikipedia


bs58 - npm based on base-x - npm

cryptocoinjs/base-x: Encode/decode any base @GitHub


base58 - npm search

base-x vs base58 vs base62 vs bs58 | npm trends


Crypto | Node.js v18.7.0 Documentation

What is Node crypto.createHash(algorithm, [options])?


base58 package - github.com/btcsuite/btcutil/base58 - Go Packages


Base58 encoding in C# (Used for BitCoin addresses)


import crypto from 'crypto';
import bs58 from 'bs58';

const sha1 = val => crypto.createHash('sha1').update(val); // Hash
const sha256 = val => crypto.createHash('sha256').update(val); // Hash

sha1(val).digest('hex'); // 40 chars.; sha256: 64 chars    
sha1(val).digest('base64'); // 28 chars; sha256: 44 chars; not "url friendly"

const sha1base58 = val => bs58.encode(sha1(val).digest()); // 28 chars, url friendly
const sha256base58 = val => bs58.encode(sha256(val).digest()); // 44 chars, url friendly


No comments: