A utility to encode and decode the string using BASE64 standard, and it supports `urlsafe` and `no-padding` options also.


1.0.13 years ago4 years agoMinified + gzip package size for @aecworks/base64-url-safe in KB



A utility to encode and decode the string using BASE64 standard, and it supports urlsafe and no-padding options also.

How to Use


this lib is packaged in the umd style. So you can just use the import or require in node environment directive to import it as a Module.

import { Base64UrlSafe } from '@aecworks/base64-url-safe';

Encode a string

test('basic test for base64 encoding', () => {
    const origin = 'urn:bimbox.file:6iNy2mA8nI/6iPzuBtMvY?version=1';
    const base64Encoded = Base64UrlSafe.encode(origin, false);

    const base64UrlSafeEncoded = Base64UrlSafe.encode(origin, true);

Decode a string

test('basic test for base64 decoding', () => {
    const originUrlSafe = 'dXJuOmJpbWJveC5maWxlOjZpTnkybUE4bkkvNmlQenVCdE12WT92ZXJzaW9uPTE';
    let base64Decoded = Base64UrlSafe.decode(originUrlSafe, true);

    const origin = 'dXJuOmJpbWJveC5maWxlOjZpTnkybUE4bkkvNmlQenVCdE12WT92ZXJzaW9uPTE=';
    base64Decoded = Base64UrlSafe.decode(origin, false);

How to Develop

  • tslint: npm run lint
  • test: npm run test
  • build: npm run build

How to publish

  • set registry: npm config set registry https://registry.npmjs.org
  • login: npm login
  • publish: npm publish

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.