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

bytes-base64

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bytes-base64

Uint8Array <-> Base64, very small size library

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
5
-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

Bytes-Base64

For converting between Uint8Array and Base64 strings. This library is primarily developed for WeChat Mini Programs and has been verified to work on mini programs.

  • Extremely small compressed size
  • No dependencies (no need to install Buffer)
  • Compatible with Node.js, browser, and WeChat Mini Programs
  • Tested with Jest

用于 Uint8ArrayBase64 字符串的相互转换,此库主要为微信小程序开发,已在小程序上验证。

  • 非常小的压缩尺寸
  • 没有任何依赖(无需安装 Buffer
  • 兼容 Node.js、浏览器,以及微信小程序
  • 通过 Jest 测试

Usage

NPM

npm i bytes-base64

YARN

yarn add bytes-base64

Example

import { bytesToBase64, base64ToBytes } from 'bytes-base64';

test('[1]', () => {
  const base64 = 'SGVsbG8gd29ybGQ=';
  const bytes = base64ToBytes(base64);
  expect(bytes).toEqual(new Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]));
});

test('[2]', () => {
  const bytes = new Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]);
  const base64 = bytesToBase64(bytes);
  expect(base64).toBe('SGVsbG8gd29ybGQ=');
});

test('[3]', () => {
  const bytes = base64ToBytes('SGVsbG8gd29ybGQ=');
  const base64 = bytesToBase64(bytes);
  expect(base64).toBe('SGVsbG8gd29ybGQ=');
});

test('[4]', () => {
  const bytes = new Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]);
  const base64 = bytesToBase64(bytes);
  const decodedBytes = base64ToBytes(base64);
  expect(decodedBytes).toEqual(bytes);
});

Keywords

bytes

FAQs

Package last updated on 22 Aug 2025

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