Socket
Socket
Sign inDemoInstall

@leichtgewicht/base64-codec

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @leichtgewicht/base64-codec

base64 to/from bytes codec (esm/cjs)


Version published
Weekly downloads
8.4K
increased by296.94%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@leichtgewicht/base64-codec

A javascript-only (esm/cjs) base64 codec that is abstract-encoding compatible, well-tested and pretty efficient. Bonus: It doesn't use Nodejs' Buffer object and comes with typescript types.

Usage

import { base64 } from '@leichtgewicht/base64-codec' // require works too!

const str = 'AA=='
const bytes = base64.encode(
  str,
  new Uint8Array(base64.encodingLength(str)), // own buffer supplied, optional
  0 // offset, at which to write the str, optional
)
str === base64.decode(bytes, 0, bytes.length)

URL Support

Use base64URL for de-/encoding for the URL variant of base64.

import { base64URL } from '@leichtgewicht/base64-codec'

Concatenated Buffer

For performance reasons, this codec does not support concatenated base64 strings.

If you need to encode concatenated strings, split them before passing them to this codec.

Why?

There are plenty of base64 implementations on NPM, but when looking into them there was none with cjs/esm support that offered positional encoding and bringing one owns buffer.

License

MIT

Keywords

FAQs

Last updated on 30 May 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc