npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

parse-base64-like-crypto-js

v0.1.0

Published

Parse Base64 and Base64URL like crypto-js, returns Uint8Array.

Readme

Parse Base64 and Base64URL like crypto-js, returns Uint8Array.

This library implements the following logic:

  • Invalid characters in the input are treated as 0 (equivalent to 'A').
  • When parsing Base64, the '=' in the input is treated as a terminator; it and any characters after it will be ignored.
  • If the last block has only 1 character, that character will be discarded.

Built for @openccw/sb3-crypto.

Setup

npm

npm i parse-base64-like-crypto-js@latest
import parseBase64 from "parse-base64-like-crypto-js";

Other Package Managers

You can also use other package managers (e.g. pnpm or yarn) in place of npm.

jsDelivr

See https://www.jsdelivr.com/package/npm/parse-base64-like-crypto-js

<script src="https://cdn.jsdelivr.net/npm/parse-base64-like-crypto-js"></script>

UNPKG

<script src="https://unpkg.com/parse-base64-like-crypto-js"></script>

Inline

You can embed browser.min.js directly into your script.
It will define the parseBase64 function using var.


Example

// Base64
parseBase64("ABCD.EFG0 12+/+/====")

// Base64URL
// It treats '=' as 0, not as a terminator.
parseBase64("ABCD.EFG0 12-_-_====", true)

// parse Base64 from bytes
var b64 = Uint8Array.of(65,66,67,68,46,69,70,71,48,32,49,50,43,47,43,47,61,61,61,61)
parseBase64(b64)

// parse Base64 with output length
parseBase64("KzdnFCBRvq3e5516c98e2044f55d85b07a4db4a185f", false, 32)

It will return a Uint8Array.


Benchmark

> pnpm benchmark
$ node scripts/benchmark.mjs
==============================================================================
 Benchmark: parse-base64-like-crypto-js vs crypto-js
 Node.js: v26.8.1 | OS: win32 x64
==============================================================================

Scenario: Small string (32 B decoded, ~44 chars Base64)
  crypto-js (parse):                      399,466 ops/s  (   2.50 µs/op)
  crypto-js (parse -> Uint8Array):        292,563 ops/s  (   3.42 µs/op)
  parseBase64:                          7,144,176 ops/s  (    140 ns/op) -> 17.88x (vs parse) / 24.42x (vs full)

Scenario: Medium string (1 KB decoded, ~1.37 KB Base64)
  crypto-js (parse):                      114,822 ops/s  (   8.71 µs/op)
  crypto-js (parse -> Uint8Array):         87,560 ops/s  (  11.42 µs/op)
  parseBase64:                            264,885 ops/s  (   3.78 µs/op) -> 2.31x (vs parse) / 3.03x (vs full)

Scenario: Large string (64 KB decoded, ~87 KB Base64)
  crypto-js (parse):                        2,076 ops/s  ( 481.69 µs/op)
  crypto-js (parse -> Uint8Array):          1,732 ops/s  ( 577.26 µs/op)
  parseBase64:                              4,653 ops/s  ( 214.90 µs/op) -> 2.24x (vs parse) / 2.69x (vs full)

Scenario: Base64URL string (1 KB decoded)
  crypto-js (parse):                       95,224 ops/s  (  10.50 µs/op)
  crypto-js (parse -> Uint8Array):         81,858 ops/s  (  12.22 µs/op)
  parseBase64:                            285,898 ops/s  (   3.50 µs/op) -> 3.00x (vs parse) / 3.49x (vs full)

Scenario: Uint8Array input (32 B decoded, ASCII bytes)
  crypto-js (parse):                      352,035 ops/s  (   2.84 µs/op)
  crypto-js (parse -> Uint8Array):        280,866 ops/s  (   3.56 µs/op)
  parseBase64:                          8,286,401 ops/s  (    121 ns/op) -> 23.54x (vs parse) / 29.50x (vs full)

Scenario: Uint8Array input (1 KB decoded, ASCII bytes)
  crypto-js (parse):                      100,676 ops/s  (   9.93 µs/op)
  crypto-js (parse -> Uint8Array):         81,310 ops/s  (  12.30 µs/op)
  parseBase64:                            394,818 ops/s  (   2.53 µs/op) -> 3.92x (vs parse) / 4.86x (vs full)

==============================================================================
 Summary Table
==============================================================================
┌─────────┬─────────────────────────────────────────────────┬───────────────────┬──────────────────┬─────────────────┬────────────────────┬───────────────────┐
│ (index) │ Scenario                                        │ crypto-js (parse) │ crypto-js (full) │ parseBase64     │ Speedup (vs parse) │ Speedup (vs full) │
├─────────┼─────────────────────────────────────────────────┼───────────────────┼──────────────────┼─────────────────┼────────────────────┼───────────────────┤
│ 0       │ 'Small string (32 B decoded, ~44 chars Base64)' │ '399.5k ops/s'    │ '292.6k ops/s'   │ '7144.2k ops/s' │ '17.88x'           │ '24.42x'          │
│ 1       │ 'Medium string (1 KB decoded, ~1.37 KB Base64)' │ '114.8k ops/s'    │ '87.6k ops/s'    │ '264.9k ops/s'  │ '2.31x'            │ '3.03x'           │
│ 2       │ 'Large string (64 KB decoded, ~87 KB Base64)'   │ '2.1k ops/s'      │ '1.7k ops/s'     │ '4.7k ops/s'    │ '2.24x'            │ '2.69x'           │
│ 3       │ 'Base64URL string (1 KB decoded)'               │ '95.2k ops/s'     │ '81.9k ops/s'    │ '285.9k ops/s'  │ '3.00x'            │ '3.49x'           │
│ 4       │ 'Uint8Array input (32 B decoded, ASCII bytes)'  │ '352.0k ops/s'    │ '280.9k ops/s'   │ '8286.4k ops/s' │ '23.54x'           │ '29.50x'          │
│ 5       │ 'Uint8Array input (1 KB decoded, ASCII bytes)'  │ '100.7k ops/s'    │ '81.3k ops/s'    │ '394.8k ops/s'  │ '3.92x'            │ '4.86x'           │
└─────────┴─────────────────────────────────────────────────┴───────────────────┴──────────────────┴─────────────────┴────────────────────┴───────────────────┘

License

Unlicense