Socket
Socket
Sign inDemoInstall

compact-base64

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compact-base64

Base64 encoding and decoding for Node.JS and browsers without polyfills


Version published
Weekly downloads
2.7K
decreased by-4.92%
Maintainers
3
Weekly downloads
 
Created
Source

compact-base64

Base64 encoding and decoding for Node.JS and browsers without polyfills.

This package provides a separate entry point in package.json for bundlers to use, this way Webpack and Browserify (other bundlers aren't tested) users will be able to use the optimized-for-browser version of the library. This means the bundlers won't need to polyfill Node.JS's Buffer.

For browser environments, the library uses btoa and atob, for Node.JS it uses Buffer.

UMD module named Base64 is available from compact-base64.js. You can use https://cdn.rawgit.com/ambassify/compact-base64-js/[tag]/compact-base64.js in your regular HTML scripts by filling in the desired tag.

Browser support

IE10 and newer + everything else

API

var Base64 = require('compact-base64');

// base64 encode
var encoded = Base64.encode("hello world");
--> aGVsbG8gd29ybGQ=

// base64 decode
var decoded = Base64.decode(encoded);
--> hello world

// convert base64 to base64url
var urlSafe = Base64.originalToUrl(encoded);
--> aGVsbG8gd29ybGQ

// convert base64 to base64url
var encoded2 = Base64.urlToOriginal(urlSafe);
--> aGVsbG8gd29ybGQ=

// base64url encode
var urlSafe2 = Base64.encodeUrl("hello world");
--> aGVsbG8gd29ybGQ

// base64url decode
var decoded = Base64.decodeUrl(urlSafe2);
--> hello world



Keywords

FAQs

Package last updated on 08 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc