All Projects → cryptocoinjs → Base X

cryptocoinjs / Base X

Licence: mit
Encode/decode any base

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Base X

Ldpc
C and MATLAB implementation for LDPC encoding and decoding
Stars: ✭ 76 (-60.21%)
Mutual labels:  encoding, decoding
Vxg.media.sdk.android
Market leading Android SDK with encoding, streaming & playback functionality
Stars: ✭ 119 (-37.7%)
Mutual labels:  encoding, decoding
Bitmatch
A Rust crate that allows you to match, bind, and pack the individual bits of integers.
Stars: ✭ 82 (-57.07%)
Mutual labels:  encoding, decoding
X509
A PHP library for X.509 public key certificates, attribute certificates, certification requests and certification path validation.
Stars: ✭ 27 (-85.86%)
Mutual labels:  encoding, decoding
Phpasn1
A PHP library to encode and decode arbitrary ASN.1 structures using ITU-T X.690 encoding rules.
Stars: ✭ 136 (-28.8%)
Mutual labels:  encoding, decoding
Rust Multibase
Multibase in rust
Stars: ✭ 30 (-84.29%)
Mutual labels:  encoding, decoding
Libbrotli
meta project to build libraries from the brotli source code
Stars: ✭ 110 (-42.41%)
Mutual labels:  encoding, decoding
Scodec
Scala combinator library for working with binary data
Stars: ✭ 709 (+271.2%)
Mutual labels:  encoding, decoding
Base58
Base58 and Base58Check implementation compatible with what is used by the bitcoin network.
Stars: ✭ 132 (-30.89%)
Mutual labels:  bitcoin, encoding
Lerc
Limited Error Raster Compression
Stars: ✭ 126 (-34.03%)
Mutual labels:  encoding, decoding
Libchef
🍀 c++ standalone header-only basic library. || c++头文件实现无第三方依赖基础库
Stars: ✭ 178 (-6.81%)
Mutual labels:  encoding, base
Go.geojson
Encoding and decoding GeoJSON <-> Go
Stars: ✭ 172 (-9.95%)
Mutual labels:  encoding, decoding
Stegify
🔍 Go tool for LSB steganography, capable of hiding any file within an image.
Stars: ✭ 927 (+385.34%)
Mutual labels:  encoding, decoding
Fast ber
A C++11 ASN.1 BER Encoding and Decoding Library
Stars: ✭ 54 (-71.73%)
Mutual labels:  encoding, decoding
Anycodable
Type-erased wrappers for Encodable, Decodable, and Codable values
Stars: ✭ 811 (+324.61%)
Mutual labels:  encoding, decoding
Binary
Generic and fast binary serializer for Go
Stars: ✭ 86 (-54.97%)
Mutual labels:  encoding, decoding
Decodify
Detect and decode encoded strings, recursively.
Stars: ✭ 670 (+250.79%)
Mutual labels:  encoding, decoding
Encoding
Go package containing implementations of efficient encoding, decoding, and validation APIs.
Stars: ✭ 705 (+269.11%)
Mutual labels:  encoding, decoding
Codability
Useful helpers for working with Codable types in Swift
Stars: ✭ 125 (-34.55%)
Mutual labels:  encoding, decoding
Ffmpeg Video Player
An FFmpeg and SDL Tutorial.
Stars: ✭ 149 (-21.99%)
Mutual labels:  encoding, decoding

base-x

NPM Package Build Status

js-standard-style

Fast base encoding / decoding of any given alphabet using bitcoin style leading zero compression.

WARNING: This module is NOT RFC3548 compliant, it cannot be used for base16 (hex), base32, or base64 encoding in a standards compliant manner.

Example

Base58

var BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
var bs58 = require('base-x')(BASE58)

var decoded = bs58.decode('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr')

console.log(decoded)
// => <Buffer 80 ed db dc 11 68 f1 da ea db d3 e4 4c 1e 3f 8f 5a 28 4c 20 29 f7 8a d2 6a f9 85 83 a4 99 de 5b 19>

console.log(bs58.encode(decoded))
// => 5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr

Alphabets

See below for a list of commonly recognized alphabets, and their respective base.

Base Alphabet
2 01
8 01234567
11 0123456789a
16 0123456789abcdef
32 0123456789ABCDEFGHJKMNPQRSTVWXYZ
32 ybndrfg8ejkmcpqxot1uwisza345h769 (z-base-32)
36 0123456789abcdefghijklmnopqrstuvwxyz
58 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
62 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
64 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
67 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~

How it works

It encodes octet arrays by doing long divisions on all significant digits in the array, creating a representation of that number in the new base. Then for every leading zero in the input (not significant as a number) it will encode as a single leader character. This is the first in the alphabet and will decode as 8 bits. The other characters depend upon the base. For example, a base58 alphabet packs roughly 5.858 bits per character.

This means the encoded string 000f (using a base16, 0-f alphabet) will actually decode to 4 bytes unlike a canonical hex encoding which uniformly packs 4 bits into each character.

While unusual, this does mean that no padding is required and it works for bases like 43.

LICENSE MIT

A direct derivation of the base58 implementation from bitcoin/bitcoin, generalized for variable length alphabets.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].