Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
@brandingbrand/utils-base64
Advanced tools
# base64 [![Build status](https://travis-ci.org/mathiasbynens/base64.svg?branch=master)](https://travis-ci.org/mathiasbynens/base64) [![Code coverage status](http://img.shields.io/coveralls/mathiasbynens/base64/master.svg)](https://coveralls.io/r/mathiasb
Weekly downloads
Readme
base64 is a robust base64 encoder/decoder that is fully compatible with atob()
and btoa()
, written in JavaScript. The base64-encoding and -decoding algorithms it uses are fully RFC 4648 compliant.
Via npm:
npm install base-64
In a browser:
<script src="base64.js"></script>
In Narwhal, Node.js, and RingoJS:
var base64 = require('base-64');
In Rhino:
load('base64.js');
Using an AMD loader like RequireJS:
require({
paths: {
base64: 'path/to/base64',
},
}, ['base64'], function (base64) {
console.log(base64);
});
base64.version
A string representing the semantic version number.
base64.encode(input)
This function takes a byte string (the input
parameter) and encodes it according to base64. The input data must be in the form of a string containing only characters in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00
to 0xFF
. The base64.encode()
function is designed to be fully compatible with btoa()
as described in the HTML Standard.
var encodedData = base64.encode(input);
To base64-encode any Unicode string, encode it as UTF-8 first:
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);
// → 'Zm9vIMKpIGJhciDwnYyGIGJheg=='
base64.decode(input)
This function takes a base64-encoded string (the input
parameter) and decodes it. The return value is in the form of a string containing only characters in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00
to 0xFF
. The base64.decode()
function is designed to be fully compatible with atob()
as described in the HTML Standard.
var decodedData = base64.decode(encodedData);
To base64-decode UTF-8-encoded data back into a Unicode string, UTF-8-decode it after base64-decoding it:
var encoded = 'Zm9vIMKpIGJhciDwnYyGIGJheg==';
var bytes = base64.decode(encoded);
var text = utf8.decode(bytes);
console.log(text);
// → 'foo © bar 𝌆 baz'
base64 is designed to work in at least Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.9, PhantomJS 1.9.0, Rhino 1.7RC4, as well as old and modern versions of Chrome, Firefox, Safari, Opera, and Internet Explorer.
After cloning this repository, run npm install
to install the dependencies needed for development and testing. You may want to install Istanbul globally using npm install istanbul -g
.
Once that’s done, you can run the unit tests in Node using npm test
or node tests/tests.js
. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use grunt test
.
To generate the code coverage report, use grunt cover
.
Mathias Bynens |
base64 is available under the MIT license.
FAQs
# base64 [![Build status](https://travis-ci.org/mathiasbynens/base64.svg?branch=master)](https://travis-ci.org/mathiasbynens/base64) [![Code coverage status](http://img.shields.io/coveralls/mathiasbynens/base64/master.svg)](https://coveralls.io/r/mathiasb
The npm package @brandingbrand/utils-base64 receives a total of 868 weekly downloads. As such, @brandingbrand/utils-base64 popularity was classified as not popular.
We found that @brandingbrand/utils-base64 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 92 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.