base64-utf8-array

base64 en-decode using utf8 Uint8Array

Usage no npm install needed!

<script type="module">
  import base64Utf8Array from 'https://cdn.skypack.dev/base64-utf8-array';
</script>

README

base64-utf8-array

Base64 en- and decoding for Uint8Arrays.

Runs on node and browsers.

Table of contents

Api

base64Decode

decodes a base64 encoded string to an Uint8Array of UTF8 chars/values

Parameters

Examples

const { base64Decode, utf8ArrayToString } = require('base64-utf8-array')
const aUtf8 = base64Decode('YWJj')
const str = utf8ArrayToString(aUtf8)
//> str = 'abc'

Returns Uint8Array

base64Encode

encodes a Uint8Array of UTF8 chars/values to a base64 encoded string

Parameters

Examples

const { stringToUtf8Array, base64Encode } = require('base64-utf8-array')
const aUtf8 = stringToUtf8Array('abc')
const sbase64 = base64Encode(aUtf8)
//> sbase64 = 'YWJj'

Returns string

utf8ArrayToString

converts a Uint8Array of UTF8 chars/values to a UTF16 string

Parameters

  • aUtf8
  • Uint8Array

Returns string UTF16 string

stringToUtf8Array

converts a UTF16 string to a Uint8Array of UTF8 chars/values

Parameters

Returns Uint8Array

Installation

Requires nodejs.

$ npm install --save base64-utf8-array

Tests

$ npm test

License

MIT licensed