base-64
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Base-64 is a robust JavaScript-base64 encoder and decoder that's fully compliant with atob()
and btoa()
, making it an extremely useful tool for developers. The algorithms for encoding and decoding comply fully with the standards outlined in the RFC 4648 section.
Usage of base-64 greatly varies depending on your development environment; however, it's simple to integrate into your project. If you're using npm, installation only requires running npm install base-64
. After installation, you can grab the module with var base64 = require('base-64')
. To encode a string into base64, simply call base64.encode(input)
, and to decode, use base64.decode(encodedData)
. It should be noted that when handling Unicode strings, these need to be UTF-8 encoded first.
Example Code usage:
var base64 = require('base-64');
var utf8 = require('utf8');
var text = 'foo Β© bar π baz';
var bytes = utf8.encode(text);
var encoded = base64.encode(bytes);
console.log(encoded);
var encodedText = 'Zm9vIMKpIGJhciDwnYyGIGJheg==';
var decodedBytes = base64.decode(encodedText);
var decodedText = utf8.decode(decodedBytes);
console.log(decodedText);
The base-64 documentation is not specified in a dedicated section, but detailed explanations and examples can be found throughout the package's README file on its GitHub repository: https://github.com/mathiasbynens/base64
.