New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

base64-uint8

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base64-uint8

This package encodes and decodes `Uint8Array`s to and from strings.

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
12
200%
Maintainers
1
Weekly downloads
 
Created
Source

Base64 encoder

This package encodes and decodes Uint8Arrays to and from strings.

There are no dependencies. It does not use atob or buffer. The input for the encoding can be any old array of numbers between 0 and 255 if you like, but the output of the decoding will be a Uint8Array.

The code is written with lots of comments and follows an example from Wikipedia to make it all easier to understand and learn from.

Simple code also usually means performant code, so I suspect this implementation is quite performant as well.

I wrote it as a quick learning project for myself.

Usage

import fs from "fs";
import { encode, decode } from './index.js';

// Buffer with the content of this README.md
const readme_bytes = fs.readFileSync("./README.md");

// Base64 string
const readme_encoded = encode(readme_bytes);

// Uint8Array that equals readme_bytes (except buffer != Uint8Array)
const readme_decoded = decode(readme_encoded);

Keywords

base64

FAQs

Package last updated on 23 Jan 2021

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