1 |
3a515b92
|
cagy
|
base64-js
|
2 |
|
|
=========
|
3 |
|
|
|
4 |
|
|
`base64-js` does basic base64 encoding/decoding in pure JS.
|
5 |
|
|
|
6 |
|
|
[![build status](https://secure.travis-ci.org/beatgammit/base64-js.png)](http://travis-ci.org/beatgammit/base64-js)
|
7 |
|
|
|
8 |
|
|
Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data.
|
9 |
|
|
|
10 |
|
|
Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does.
|
11 |
|
|
|
12 |
|
|
## install
|
13 |
|
|
|
14 |
|
|
With [npm](https://npmjs.org) do:
|
15 |
|
|
|
16 |
|
|
`npm install base64-js` and `var base64js = require('base64-js')`
|
17 |
|
|
|
18 |
|
|
For use in web browsers do:
|
19 |
|
|
|
20 |
|
|
`<script src="base64js.min.js"></script>`
|
21 |
|
|
|
22 |
|
|
## methods
|
23 |
|
|
|
24 |
|
|
`base64js` has three exposed functions, `byteLength`, `toByteArray` and `fromByteArray`, which both take a single argument.
|
25 |
|
|
|
26 |
|
|
* `byteLength` - Takes a base64 string and returns length of byte array
|
27 |
|
|
* `toByteArray` - Takes a base64 string and returns a byte array
|
28 |
|
|
* `fromByteArray` - Takes a byte array and returns a base64 string
|
29 |
|
|
|
30 |
|
|
## license
|
31 |
|
|
|
32 |
|
|
MIT
|