Coder Social home page Coder Social logo

base45's Introduction

RFC 9285 Base45 Encoder/Decoder (@digitalbazaar/base45)

Encoder/decoder for The Base45 Data Encoding for Node.js and Web browsers

Table of Contents

Background

This library provides an encoder and decoder for RFC 9285 [The Base45 Encoding Scheme][] using an alphabet designed for efficient use in QR codes using Alphanumeric mode. It works in both Node.js and in Web browsers with no dependencies.

Install

  • Node.js >=18 is supported.

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

npm install @digitalbazaar/base45

To install locally or for development:

git clone https://github.com/digitalbazaar/base45.git
cd base45
npm install

Usage

import {encode, decode} from '@digitalbazaar/base45';

Encoding

  • encode(input])
    • input: Uint8Array - bytes to encode
    • Returns a base45 encoded string.
import {encode} from '@digitalbazaar/base45';

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

Decoding

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

const input2 = 'X507H0';
const decoded2 = decode(input2);
// > Uint8Array [ 1, 2, 3, 4 ]

String Handling

This library uses Uint8Array for encoder input and decoder output. If conversion to and from strings is needed it can be done with a variety of tools such as TextEncoder and TextDecoder using the Encoding standard.

const input3 = new TextEncoder().encode('abc');
const encoded3 = encode(input3);
// > 0EC92

const decoded4 = decode(encoded3);
const output4 = new TextDecoder().decode(decoded4);
// > abc

Security

  • Processing large inputs could result in high resource usage.

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

base45's People

Contributors

davidlehn avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

procivis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.