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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@procivis/base58-universal

v2.0.1-0

Published

Encode/decode using "The Base58 Encoding Scheme".

Downloads

251

Readme

Base58 Universal Encoder/Decoder (@procivis/base58-universal)

NPM Version

Encoder/decoder for The Base58 Encoding Scheme for Node.js and Web browsers

Table of Contents

Security

TBD

Background

(Forked from digitalbazaar/base58-universal to provide TypeScript compatibility.)

This library provides an encoder and decoder for The Base58 Encoding Scheme using an alphabet popularized by Bitcoin. It works in both Node.js and in Web browsers with no dependencies.

Install

  • Node.js >=14 required.

To install for Node.js or in a Web project using npm:

npm install @digitalcredentials/base58-universal

To install locally or for development:

git clone https://github.com/digitalcredentials/base58-universal.git
cd base58-universal
npm install

Usage

The library can be loaded with CommonJS or ESM:

const {encode, decode} = require('@procivis/base58-universal');
import {encode, decode} from '@procivis/base58-universal';

Encoding

  • encode(input[, maxline])
    • input: Uint8Array - bytes to encode
    • maxline: Number - maximum number of encoded characters per line to use, defaults to infinite.
    • Returns a base58 encoded string.
import {encode} from 'base58-universal';

const input1 = Uint8Array([1, 2, 3, 4]);
const encoded1 = encode(input1);
// > 2VfUX

const input2 = Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const encoded2 = encode(input2, 8);
// > 4HUtbHhN\r\n2TkpR

Decoding

  • decode(input)
    • input: String - string to decode
    • Returns a Uint8Array with the decoded bytes.
import {decode} from 'base58-universal';

const input3 = '2VfUX';
const decoded3 = decode(input3);
// > Uint8Array [ 1, 2, 3, 4 ]

const input4 = '4HUtbHhN\r\n2TkpR';
const decoded4 = decode(input4);
// > Uint8Array [
//   1, 2, 3, 4,  5,
//   6, 7, 8, 9, 10
// ]

String Handling

This library uses Uint8Array for encoder input and decoder output. Conversion to and from strings can be done with a variety of tools.

Browser

const input5 = new TextEncoder().encode('abc');
const encoded5 = encode(input5);
// > ZiCa

const decoded6 = decode(encoded5);
const output6 = new TextDecoder().decode(decoded6);
// > abc

Node.js

const input7 = new TextEncoder().encode('abc');
const encoded7 = encode(input7);
// > ZiCa

const decoded8 = decode(encoded7);
const output8 = new TextDecoder().decode(decoded8);
// > abc

// Using Buffer (which is a Uint8Array)
const input9 = Buffer.from('616263', 'hex');
const encoded9 = encode(input9);
const decoded9 = decode(encoded9);
Buffer.from(decoded9).toString();
// > abc
Buffer.from(decoded9).toString('hex');
// > 616263

Contribute

Please follow the Bedrock contributing guidelines.

PRs accepted.

If editing the README, please conform to the standard-readme specification.

Commercial Support

Commercial support for this library is available upon request from Digital Bazaar: [email protected]

License

New BSD License (3-clause) © Digital Bazaar

Encoder/decoder original implementation from base-x under the MIT License.