Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gghez/meteor-base58
Encode / Decode using Base58 algorithm.
https://github.com/gghez/meteor-base58
Last synced: about 1 month ago
JSON representation
Encode / Decode using Base58 algorithm.
- Host: GitHub
- URL: https://github.com/gghez/meteor-base58
- Owner: gghez
- Created: 2016-01-29T17:29:16.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-30T00:34:47.000Z (almost 9 years ago)
- Last Synced: 2023-08-07T17:13:15.445Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Base58
[![Build Status](https://travis-ci.org/gghez/meteor-base58.svg?branch=master)](https://travis-ci.org/gghez/meteor-base58)
Encode / Decode using Base58 algorithm. Simplified usage to deal with `String` as well as `Buffer` and `Array`.
*Port from NPM Module [base-x](https://www.npmjs.com/package/base-x)*
Used alphabet: `123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`
## Installation
```
meteor add gghez:base58
```## Usage
Client or Server side, global `Base58` is available:
```js
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:
```js
if (Meteor.isServer){
var buffer = new Buffer('this is a clear sentence.');
encoded = Base58.encode(buffer);
}
```Decoding a Base58 string is very simple:
```js
Base58.decode('oqj3pKcxTmxVvrcVqyiFSCL5LkvsXjTYBX');
// 'this is a clear sentence.'Base58.decodeArray('oqj3pKcxTmxVvrcVqyiFSCL5LkvsXjTYBX');
// [116, 104, 105...]```
## API
### Base58.encode(source)
Encodes a `String`, `Array` or `Buffer` to **Base58** string. Note that `Buffer` encoding is only available on Server (NodeJS context).
### Base58.decode(encoded)
Decodes an encoded Base58 string to a `String`.
### Base58.decodeArray(encoded)
Decodes a string into a byte array.