Encode / Decode using Base58 algorithm. Simplified usage to deal with String as well as Buffer and Array.
Port from NPM Module base-x
Used alphabet: 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
meteor add gghez:base58
Client or Server side, global Base58 is available:
var encoded = Base58.encode('this is a clear sentence.');
// encoded == 'oqj3pKcxTmxVvrcVqyiFSCL5LkvsXjTYBX'You can also use a Buffer as input for Base58.encode on Server where NodeJS provides Buffer object:
if (Meteor.isServer){
var buffer = new Buffer('this is a clear sentence.');
encoded = Base58.encode(buffer);
}Decoding a Base58 string is very simple:
Base58.decode('oqj3pKcxTmxVvrcVqyiFSCL5LkvsXjTYBX');
// 'this is a clear sentence.'
Base58.decodeArray('oqj3pKcxTmxVvrcVqyiFSCL5LkvsXjTYBX');
// [116, 104, 105...]Encodes a String, Array or Buffer to Base58 string. Note that Buffer encoding is only available on Server (NodeJS context).
Decodes an encoded Base58 string to a String.
Decodes a string into a byte array.