base64url-arraybuffer

1.1.0 • Public • Published

Base64URL-ArrayBuffer

npm version

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 ]

Package Sidebar

Install

npm i base64url-arraybuffer

Weekly Downloads

88

Version

1.1.0

License

MIT

Unpacked Size

16.5 kB

Total Files

7

Last publish

Collaborators

  • deepu105