Base32 encoding/decoding (#652)

* Base32 encoding/decoding

* Attribution

* LOOKUP

* Share base32/58 alphabet validation

* Apply suggestions from code review
This commit is contained in:
Jaco Greeff
2020-08-09 13:27:47 +02:00
committed by GitHub
parent 4529bc37b5
commit 9d145e72b8
12 changed files with 232 additions and 11 deletions
+6 -2
View File
@@ -12,8 +12,12 @@ import { bs58 } from './bs58';
* @description
* From the provided input, create the base58 and return the result as a string.
*/
export default function base58Encode (value: Uint8Array | string | Buffer | number[]): string {
return bs58.encode(
export default function base58Encode (value: Uint8Array | string | Buffer | number[], ipfsCompat = false): string {
const out = bs58.encode(
u8aToBuffer(u8aToU8a(value))
);
return ipfsCompat
? `z${out}`
: out;
}