MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / encodeBase58

Function encodeBase58

lib.esm/utils/base58.js:35–51  ·  view source on GitHub ↗
(_value)

Source from the content-addressed store, hash-verified

33 * Encode %%value%% as a Base58-encoded string.
34 */
35export function encodeBase58(_value) {
36 const bytes = getBytes(_value);
37 let value = toBigInt(bytes);
38 let result = "";
39 while (value) {
40 result = Alphabet[Number(value % BN_58)] + result;
41 value /= BN_58;
42 }
43 // Account for leading padding zeros
44 for (let i = 0; i < bytes.length; i++) {
45 if (bytes[i]) {
46 break;
47 }
48 result = Alphabet[0] + result;
49 }
50 return result;
51}
52/**
53 * Decode the Base58-encoded %%value%%.
54 */

Callers 4

getContentHashMethod · 0.90
encodeBase58CheckFunction · 0.90
getContentHashMethod · 0.90
encodeBase58CheckFunction · 0.90

Calls 2

getBytesFunction · 0.90
toBigIntFunction · 0.90

Tested by

no test coverage detected