grjan7 / b64-cjs

A library to encode to and decode from base64, similar to atob btoa of native JavaScript functions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

b64-cjs

NPM version NPM downloads Known Vulnerabilities

A library to encode to and decode from base64, similar to atob btoa of native JavaScript functions.

Installation

  $ npm install b64-cjs

base64.encode(plainStr)

  const Base64 = require('b64-cjs');

  const myObj = {name: "john", age: 30};
  const myObjString = JSON.stringify(myObj);
  const base64EncodedString = Base64.encode(myObjString);

  console.log(base64EncodedString);

base64.decode(base64Str)

  const Base64 = require('b64-cjs');

  const myObj = {name: "john", age: 30};
  const myObjString = JSON.stringify(myObj);
  const base64EncodedString = Base64.encode(myObjString);

  const decodedBase64String = Base64.decode(base64EncodedMyObj);
  
  console.log(JSON.parse(decodedBase64String));

About

A library to encode to and decode from base64, similar to atob btoa of native JavaScript functions.

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%