You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@protobufjs/base64

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@protobufjs/base64

A minimal base64 implementation for number arrays.


Version published
Weekly downloads
10M
decreased by-17.93%
Maintainers
2
Install size
10.0 kB
Created
Weekly downloads
 

Package description

What is @protobufjs/base64?

@protobufjs/base64 is a utility library for encoding and decoding base64 strings, primarily used in conjunction with Protocol Buffers in JavaScript. It provides efficient and straightforward methods to handle base64 encoding and decoding operations.

What are @protobufjs/base64's main functionalities?

Base64 Encoding

This feature allows you to encode a Uint8Array into a base64 string. The `encode` method takes a buffer, an offset, and a length as parameters.

const base64 = require('@protobufjs/base64');

const buffer = new Uint8Array([72, 101, 108, 108, 111]);
let encoded = base64.encode(buffer, 0, buffer.length);
console.log(encoded); // Outputs: SGVsbG8=

Base64 Decoding

This feature allows you to decode a base64 string back into a Uint8Array. The `decode` method takes a base64 string, a buffer to write to, and an offset as parameters.

const base64 = require('@protobufjs/base64');

const encoded = 'SGVsbG8=';
let buffer = new Uint8Array(encoded.length);
let length = base64.decode(encoded, buffer, 0);
console.log(buffer.subarray(0, length)); // Outputs: Uint8Array(5) [ 72, 101, 108, 108, 111 ]

Other packages similar to @protobufjs/base64

Readme

Source

@protobufjs/base64

npm

A minimal base64 implementation for number arrays.

API

  • base64.length(string: string): number
    Calculates the byte length of a base64 encoded string.

  • base64.encode(buffer: Uint8Array, start: number, end: number): string
    Encodes a buffer to a base64 encoded string.

  • base64.decode(string: string, buffer: Uint8Array, offset: number): number
    Decodes a base64 encoded string to a buffer.

License: BSD 3-Clause License

FAQs

Package last updated on 09 Jun 2017

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc