Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including awesome-urlsafe-base64 with all npm packages installed. Try it out:

var awesomeUrlsafeBase64 = require("awesome-urlsafe-base64")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

awesome-urlsafe-base64 v1.1.2

A very simple base64 encoder that produces URL safe base64 encodings.

Build Status codecov

awesome-urlsafe-base64


This is a simple utility that will do base64 encoding and then do some replacing of the URL unfriendly characters that are potentially added during the base64 encoding.

This utility is somewhat compatible with the existing urlsafe-base64 NPM module.

Eventually this library will support Variants of the Base64 algorithm.

.encodeBuffer(buffer) :: string

Encodes a buffer as an URL Safe Base64-like string. This function encodes to the RFC 4648 Spec where '+' is encoded as '-' the '/' is encoded as '_' and the padding character '=' is encoded as '.'.

var AwesomeBase64 = require('awesome-urlsafe-base64');
var buffer = new Buffer('http://www.encode.me/please/kthxbye');
var encodedString = AwesomeBase64.encode(buffer);

.decodeBuffer(string) :: buffer

Decodes a previously encoded string.

var AwesomeBase64 = require('awesome-urlsafe-base64');
var toDecode = 'VWJlciBTdHJpbmcgdG8gRW5jb2Rl';
var buffer = AwesomeBase64.decode(toDecode);

.encodeString(string) :: string

Encodes a string.

var AwesomeBase64 = require('awesome-urlsafe-base64');
var toEncode = 'http://www.encode.me/please/kthxbye';
var encodedString = AwesomeBase64.encode(buffer);

.decodeString(string) :: string

Decodes a string.

var AwesomeBase64 = require('awesome-urlsafe-base64');
var toDecode = 'VWJlciBTdHJpbmcgdG8gRW5jb2Rl';
var decodedString = AwesomeBase64.encode(buffer);

.encode(buffer) :: string

Alias for .encodeBuffer

.decode(string) :: buffer

Alias for .decodeBuffer

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free