Skip to main content

Base85 encoder/decoder.

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
100%
Published
2 weeks ago

@nurliman/base85 is a Base85 encoder and decoder that compatible for Node.js and browser.

Usage

Import the package into your project:

import { encodeBase85, decodeBase85 } from "@nurliman/base85";

const encoded = encodeBase85("your string");
const decoded = decodeBase85(encoded);

using default import:

import base85 from "@nurliman/base85";

const encoded = base85.encode("your string");
const decoded = base85.decode(encoded);

using require:

const { encodeBase85, decodeBase85 } = require("@nurliman/base85");

const encoded = encodeBase85("your string");
const decoded = decodeBase85(encoded);

Please replace 'your string' with the string you want to encode and decode.

EncodeOptions

EncodeOptions is an object that can be passed to the encode function to customize its behavior. It has the following properties:

  • wrap: If true, the encoded string will be wrapped in <~ and ~>. Defaults to true.

Here's an example of how to use it:

import base85 from "@nurliman/base85";

const result = base85.encode("Hello World!");
console.log(result);
// <~87cURD]i,"Ebo80~>

const result = base85.encode("Hello World!", {
  wrap: false, // Set this to false if you don't want the output to be wrapped
});
console.log(result);
// 87cURD]i,"Ebo80

Decode

import base85 from "@nurliman/base85";

const result = base85.decode('<~87cURD]i,"Ebo80~>');
console.log(result);
// Hello World!

// it also works without the wrapping characters
const result = base85.decode('87cURD]i,"Ebo80');
console.log(result);
// Hello World!
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @nurliman/base85

Import symbol

import * as mod from "@nurliman/base85";

Add Package

npx jsr add @nurliman/base85

Import symbol

import * as mod from "@nurliman/base85";

Add Package

yarn dlx jsr add @nurliman/base85

Import symbol

import * as mod from "@nurliman/base85";

Add Package

pnpm dlx jsr add @nurliman/base85

Import symbol

import * as mod from "@nurliman/base85";

Add Package

bunx jsr add @nurliman/base85

Import symbol

import * as mod from "@nurliman/base85";