base64url-arraybuffer
v1.1.0
Published
Encode and Decode Base64URLs into ArrayBuffers
Downloads
17
Maintainers
Readme
Base64URL-ArrayBuffer
Converts between Base64URL and ArrayBuffer.
Available functions
// Encode an ArrayBuffer to a base64url string.
encode(buffer:ArrayBuffer) : string
// Decode a base64url string to an ArrayBuffer.
decode(base64url: string) : ArrayBuffer
// Utilities
// Convert a string to an ArrayBuffer.
arrayBufferToString(buffer: ArrayBuffer) : string
// Convert an ArrayBuffer to a string.
stringToArrayBuffer(str: string) : ArrayBuffer
Getting Started
This library can be used on Node.js and Browser
Node.js/AMD
npm install base64url-arraybuffer
ESM
import { encode, decode } from "base64url-arraybuffer";
const base64url = encode(arrayBuffer);
const arrayBuffer = decode(base64url);
CommonJS
const base64url = require("base64url-arraybuffer");
const base64urlString = base64url.encode(arrayBuffer);
const arrayBuffer = base64url.decode(base64urlString);
Browser
<script src="https://unpkg.com/base64url-arraybuffer"></script>
<script>
const base64url = base64url.encode(arrayBuffer);
const arrayBuffer = base64url.decode(base64url);
</script>
License
MIT
Crafted by
Deepu K Sasidharan [ website | Linkedin | GitHub | Twitter | Mastodon ]