(_value)
| 33 | * Encode %%value%% as a Base58-encoded string. |
| 34 | */ |
| 35 | export 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 | */ |
no test coverage detected