convertlib 3.7.0
convertlib: ^3.7.0 copied to clipboard
Fast and error resilient codecs. Supports Base2, Base8, Base16, Base32, Base64, BigInt, UTF-8, and the PHC/crypt string format.
convertlib
Fast, error-resilient, zero-dependency codecs for Dart.
Binary · Octal · Hex · Base-32 · Base-36 · Base-45 · Base-58 · Base-62 · Base-64 · Base-85 · Bech32 · Punycode · Percent / URL · BigInt · UTF-8 · PHC / Modular Crypt
A pure-Dart library of fast, error-resilient codecs: binary, octal, hex, Base-32, Base-36, Base-45, Base-58, Base-62, Base-64, Base-85, Bech32, Punycode, percent (URL) encoding, BigInt, UTF-8, and the PHC / Modular Crypt Format — with a rich set of alphabet variants, optional padding, and zero dependencies.
convertlib is the foundation layer of a three-package family:
Both hashlib (hashes, MACs, KDFs) and cipherlib (ciphers, AEAD, ML-KEM)
build on it, reusing its codecs to render digests, keys, and ciphertext as
text. It carries no runtime dependencies of its own.
✨ Highlights #
| Feature | What you get | |
|---|---|---|
| 🌍 | Runs on every platform | Pure Dart with no native code or FFI — the same library works on the VM, Flutter (Android, iOS, Windows, macOS, Linux), and the web (dart2js and dart2wasm). |
| 📦 | Zero dependencies | Nothing is pulled into your dependency tree. |
| 🔡 | Broad coverage | Base-2, Base-8, Base-16, Base-32, Base-36, Base-45, Base-58, Base-62, Base-64, Base-85, Bech32, Punycode, percent (URL) encoding, BigInt, UTF-8, and the PHC / Modular Crypt Format, each with a symmetrical to/from pair. |
| 🎛️ | Many alphabet variants | RFC 4648 standard, base32hex, Crockford, z-base-32, geohash, word-safe, URL/filename-safe Base-64, bcrypt, and IMAP. |
| ✳️ | Optional padding | Encode and decode with or without = padding. |
| 🛡️ | Error resilient | Decoders accept case and alphabet variations where the encoding allows it, and raise typed errors on genuinely invalid input. |
| 🧩 | Convenient output | Results integrate with ByteCollector, the digest container shared with hashlib, for one-call re-encoding. |
| ⚙️ | Bytes or strings, throwing or not | Every encoder has a to<Name>Bytes twin returning a Uint8List, every decoder a non-throwing tryFrom<Name> returning null, plus a top-level constantTimeEquals. |
📦 Install #
dependencies:
convertlib: ^3.7.0
or run dart pub add convertlib. A single import exposes every codec:
import 'package:convertlib/convertlib.dart';
Full API reference: convertlib library.
⚡ Quickstart #
Every codec exposes a to<Name> encoder and a from<Name> decoder that are
exact inverses of each other:
import 'package:convertlib/convertlib.dart';
void main() {
final data = toUtf8('convertlib');
// Encode the same bytes in a few common ways
final hex = toHex(data);
final b64 = toBase64(data);
final b32 = toBase32(data);
print('bytes : $data');
print('hex : $hex');
print('base64 : $b64');
print('base32 : $b32');
// Every encoder has an exact inverse
print('decoded: ${fromUtf8(fromHex(hex))}');
print('match : ${fromUtf8(fromBase64(b64)) == 'convertlib'}');
}
Every snippet in this README is also a runnable program in the example folder.
🧬 Supported codecs #
| Encoding | Class | Encode | Decode | Source |
|---|---|---|---|---|
| Binary (Base-2) | Base2Codec |
toBinary, toBinaryBytes |
fromBinary, tryFromBinary |
— |
| Octal (Base-8) | Base8Codec |
toOctal, toOctalBytes |
fromOctal, tryFromOctal |
— |
| Hexadecimal (Base-16) | Base16Codec |
toHex, toHexBytes |
fromHex, tryFromHex |
RFC-4648 |
| Base-32 | Base32Codec |
toBase32, toBase32Bytes |
fromBase32, tryFromBase32 |
RFC-4648 |
| Base-36 | Base36Codec |
toBase36, toBase36Bytes |
fromBase36, tryFromBase36 |
— |
| Base-45 | Base45Codec |
toBase45, toBase45Bytes |
fromBase45, tryFromBase45 |
RFC-9285 |
| Base-58 | Base58Codec |
toBase58, toBase58Bytes |
fromBase58, tryFromBase58 |
Draft |
| Base-62 | Base62Codec |
toBase62, toBase62Bytes |
fromBase62, tryFromBase62 |
— |
| Base-64 | Base64Codec |
toBase64, toBase64Bytes |
fromBase64, tryFromBase64 |
RFC-4648 |
| Base-85 | Base85Codec |
toBase85, toBase85Bytes |
fromBase85, tryFromBase85 |
Ascii85, Z85 |
| Bech32 | Bech32Codec |
toBech32 |
fromBech32, tryFromBech32 |
BIP-173, BIP-350 |
| SegWit address | SegwitCodec |
toSegwitAddress |
fromSegwitAddress, tryFromSegwitAddress |
BIP-173, BIP-350 |
| Punycode | PunycodeCodec |
toPunycode |
fromPunycode, tryFromPunycode |
RFC-3492, RFC-3490 |
| Percent (URL) | PercentCodec |
toPercent, toPercentBytes |
fromPercent, tryFromPercent |
RFC-3986 |
| BigInt | BigIntCodec |
toBigInt |
fromBigInt, tryFromBigInt |
— |
| UTF-8 | UTF8Codec |
toUtf8 |
fromUtf8, tryFromUtf8 |
RFC-3629 |
| Modular Crypt Format | CryptFormat |
toCrypt |
fromCrypt |
PHC string format |
🔤 Alphabet variants #
Base-16 — toHex(..., upper: true) selects the uppercase alphabet:
Base16Codec.upper—0123456789ABCDEFBase16Codec.lower—0123456789abcdef(default)
Base-32 — pass codec: to pick an alphabet, lower:/padding: to tweak it:
Base32Codec.standard(RFC-4648) —ABCDEFGHIJKLMNOPQRSTUVWXYZ234567(default)Base32Codec.lowercase—abcdefghijklmnopqrstuvwxyz234567Base32Codec.hex/.hexLower— base32hex,0-9A-V/0-9a-vBase32Codec.crockford—0123456789ABCDEFGHJKMNPQRSTVWXYZ(decoding is case-insensitive and acceptsI/i/L/las1andO/oas0)Base32Codec.geohash—0123456789bcdefghjkmnpqrstuvwxyzBase32Codec.z— z-base-32,ybndrfg8ejkmcpqxot1uwisza345h769Base32Codec.wordSafe—23456789CFGHJMPQRVWXcfghjmpqrvwx
Base-36 — toBase36(..., upper: true) selects the uppercase alphabet.
Decoding accepts both cases. Each leading zero byte is written as 0, and
there is no padding:
Base36Codec.standard—0123456789abcdefghijklmnopqrstuvwxyz(default)Base36Codec.upper—0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
Base-45 (RFC-9285, the alphanumeric mode of QR codes) — each group of 2 bytes is written as 3 characters, and a final byte as 2. There is no padding, and decoding accepts only uppercase:
Base45Codec.standard—0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:(default; note the space)
Base-58 — pass a codec: to pick an alphabet. Each leading zero byte is
written as the alphabet's first character, and there is no padding:
Base58Codec.standard(Bitcoin) —123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz(default)Base58Codec.flickr—123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZBase58Codec.ripple—rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz
Base-62 — no standard fixes the letter order, so pass lowerFirst: true
(to encode and to decode) or a codec: to match the other side. Each leading
zero byte is written as 0, and there is no padding:
Base62Codec.standard—0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz(default)Base62Codec.lowerFirst—0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Base-64 — pass url: true for URL/filename-safe output, padding: false
to drop =, or a codec::
Base64Codec.standard(RFC-4648) —A-Za-z0-9+/(default)Base64Codec.urlSafe—A-Za-z0-9-_Base64Codec.bcrypt—./A-Za-z0-9Base64Codec.imap(RFC-3501) —A-Za-z0-9+,
Base-85 — pass a codec: to pick a variant. Each group of 4 bytes is
written as 5 characters:
Base85Codec.standard(Ascii85, as in PostScript and PDF) — the 85 characters from!tou(default). An all-zero group is written asz; decoding also accepts a<~ ~>frame and whitespace.Base85Codec.z85(ZeroMQ) —0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#(whole groups only: a multiple of 4 bytes)Base85Codec.git(git binary patches, Python'sb85encode) —0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~Base85Codec.ipv6(RFC 1924) — exactly 16 bytes as one 20-character number, with thegitalphabet
Bech32 — a human-readable part, the separator 1, a data part of 5-bit
words, and a 6-character checksum, with the alphabet
qpzry9x8gf2tvdw0s3jn54khce6mua7l. toBech32(hrp, bytes) regroups bytes into
5-bit words, as Nostr keys do; fromBech32 returns a Bech32Data with the
hrp, the words, and the bytes. Pass m: true or a codec::
Bech32Codec.bech32(BIP-173) — checksum constant1, at most 90 characters (default)Bech32Codec.bech32m(BIP-350) — checksum constant0x2bc830a3, at most 90 charactersBech32Codec.lightning— Bech32 without the length limit, as BOLT 11 invoices use it
toSegwitAddress(hrp, version, program) and fromSegwitAddress(address)
handle Bitcoin SegWit addresses, choosing Bech32 for version 0 and Bech32m for
later versions such as Taproot.
Punycode (RFC 3492) — the encoding of internationalized domain names: the
ASCII characters, a -, then the other characters as base-36 numbers with the
digits abcdefghijklmnopqrstuvwxyz0123456789 (decoding accepts both cases).
Pass domain: true or a codec::
PunycodeCodec.standard— the whole string, without a prefix:bücher⇄bcher-kva(default)PunycodeCodec.domain— each non-ASCII label of a domain name, with the IDNA prefixxn--:münchen.de⇄xn--mnchen-3ya.de. It does not lowercase or normalize the labels (Nameprep / UTS #46).
Percent / URL (RFC 3986) — each byte outside the unreserved characters is
written as % and two uppercase hex digits: the UTF-8 of a b/é ⇄
a%20b%2F%C3%A9. It encodes any bytes, unlike Uri.encodeComponent, which
encodes the UTF-8 of a string. Decoding accepts both cases and keeps any other
ASCII character. Pass component: true, form: true, or a codec::
PercentCodec.standard— keeps the RFC 3986 unreserved charactersABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~(default)PercentCodec.component— also keeps!'()*, matchingUri.encodeComponentand JavaScript'sencodeURIComponent:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!'()*PercentCodec.form— HTML form query strings, matchingUri.encodeQueryComponent: keepsABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~, and writes a space as+(decoding reads+as a space)PercentCodec.custom(unreserved, spaceAsPlus: false)— keeps exactly the ASCII characters you list
BigInt — endianness is selectable via msbFirst or an explicit codec:
BigIntCodec.msbFirst— treats bytes in big-endian orderBigIntCodec.lsbFirst— treats bytes in little-endian order (default)
UTF-8 — pass allowMalformed: true (or a codec:) to decode ill-formed
input instead of throwing:
UTF8Codec.standard— rejects ill-formed input with aFormatException(default)UTF8Codec.lenient— clips input values outside0..255to their low 8 bits and replaces each ill-formed sequence withU+FFFD, asdart:convertdoes
🧰 Bytes, non-throwing decode, and constant-time compare #
- Byte output — the
to<Name>Bytesencoders in the table above return the encoded ASCII as aUint8List, skipping the intermediateString. - Non-throwing decoders — the
tryFrom<Name>decoders returnnullinstead of throwing aFormatExceptionon invalid input. - Constant-time compare —
constantTimeEquals(a, b)compares two byte lists without exiting early on the first mismatch, for verifying MACs and digests. - Whole inputs only — the codecs convert a complete input at once. Chunked
conversion (
startChunkedConversion,Stream.transform) is not supported and throws anUnsupportedError, so collect a stream first, for example with aBytesBuilder. - Low-level building blocks — the generic converters
BitEncoder/BitDecoder,ByteEncoder/ByteDecoder, andAlphabetEncoder/AlphabetDecoderare exported for building custom codecs.
📥 ByteCollector #
ByteCollector is the byte container shared with hashlib, holding the output
of a hash or encoding function and re-encoding it on demand:
| Method / getter | Description |
|---|---|
bytes |
Raw bytes as Uint8List |
length |
Number of bytes |
buffer |
The backing ByteBuffer |
hex([upper]) |
Hexadecimal string (optionally uppercase) |
binary() / octal() |
Binary / octal string representation |
base32({upper, padding}) |
Base-32 encoding |
base64({urlSafe, padding}) |
Base-64 encoding |
base36({upper}) |
Base-36 encoding |
base45() |
Base-45 encoding (RFC 9285) |
base58({codec}) |
Base-58 encoding (Bitcoin alphabet default) |
base62({lowerFirst}) |
Base-62 encoding |
base85({codec}) |
Base-85 encoding (Ascii85 default) |
bech32(hrp, {m, codec}) |
Bech32 / Bech32m string with the human-readable hrp |
bigInt({endian}) |
Interprets the bytes as a BigInt (big endian default) |
number([bitLength, endian]) |
Reads an unsigned integer of the given bit-length |
ascii() / utf8() |
Decodes bytes as ASCII / UTF-8 (allowMalformed) |
to(encoding) |
Decodes bytes with a given dart:convert Encoding |
isEqual(other) |
Constant-time compare against bytes, buffer, or hex text |
🍳 Recipes #
Base-32 alphabet variants #
The same bytes, rendered in each supported Base-32 alphabet — useful for human-friendly identifiers (Crockford), URLs (z-base-32), or geospatial codes (geohash):
import 'package:convertlib/convertlib.dart';
void main() {
final data = toUtf8('Hello, convertlib!');
print('standard : ${toBase32(data)}');
print('lowercase : ${toBase32(data, lower: true)}');
print('no padding : ${toBase32(data, padding: false)}');
print('base32hex : ${toBase32(data, codec: Base32Codec.hex)}');
print('crockford : ${toBase32(data, codec: Base32Codec.crockford)}');
print('z-base-32 : ${toBase32(data, codec: Base32Codec.z)}');
print('geohash : ${toBase32(data, codec: Base32Codec.geohash)}');
print('word-safe : ${toBase32(data, codec: Base32Codec.wordSafe)}');
// Decoding is the exact inverse of encoding
final back = fromBase32(toBase32(data));
print('roundtrip : ${fromUtf8(back)}');
}
URL-safe and unpadded Base-64 #
For tokens embedded in URLs or JSON, drop the padding and switch to the URL/filename-safe alphabet:
import 'package:convertlib/convertlib.dart';
void main() {
final data = toUtf8('a >> b, c/d');
print('standard : ${toBase64(data)}');
print('url-safe : ${toBase64(data, url: true)}');
print('no padding : ${toBase64(data, url: true, padding: false)}');
print('bcrypt : ${toBase64(data, codec: Base64Codec.bcrypt)}');
print('imap : ${toBase64(data, codec: Base64Codec.imap)}');
// Decode back to the original bytes
final back = fromBase64(toBase64(data, url: true));
print('roundtrip : ${fromUtf8(back)}');
}
BigInt ↔ bytes #
Read a byte sequence as an arbitrary-precision integer and back. Combine with
BigInt.toRadixString for a decimal (or any-base) string representation:
import 'package:convertlib/convertlib.dart';
void main() {
var input = [0x3, 0xF1];
print("input => $input");
var encoded = toBigInt(input).toRadixString(10);
print("to decimal => $encoded");
var decoded = fromBigInt(BigInt.parse(encoded, radix: 10));
print("from decimal => $decoded");
}
PHC / Modular Crypt Format #
Build and parse password-hash strings such as
$argon2id$v=19$m=65536,t=3,p=4$...$.... The builder Base-64 encodes salt and
hash bytes for you, and fromCrypt gives the fields back as typed accessors:
import 'package:convertlib/convertlib.dart';
void main() {
// Build a PHC / Modular Crypt Format string from its parts.
// `saltBytes` and `hashBytes` are Base-64 encoded (no padding) for you.
final data = CryptData.builder('argon2id')
.version('19')
.param('m', 65536)
.param('t', 3)
.param('p', 4)
.saltBytes(toUtf8('a-16-byte-salt!!'))
.hashBytes(List.generate(32, (i) => i))
.build();
final encoded = toCrypt(data);
print('encoded : $encoded');
// Parse the string back into its structured fields.
final parsed = fromCrypt(encoded);
print('id : ${parsed.id}');
print('version : ${parsed.versionInt()}');
print('m,t,p : ${parsed.getIntParam('m')}, '
'${parsed.getIntParam('t')}, ${parsed.getIntParam('p')}');
print('salt : ${fromUtf8(parsed.saltBytes()!)}');
print('hash : ${toHex(parsed.hashBytes()!)}');
}
🧪 Testing and reliability #
Codecs are trivial to get subtly wrong. It is not enough to check just the
decode(encode(x)) == x round-trips alone. For example: a dropped bit mask
can produce output that still passes round-trips cleanly. This package is
tested against that failure mode directly:
- Expectations come from outside the code. Every codec is checked against
official vectors (RFC 4648 "foobar", RFC 3629 UTF-8 boundaries, PHC / bcrypt
strings) and differentially against independent reference implementations:
dart:convert,base_codecs, andbase32, so a consistently-wrong codec cannot hide behind a passing round-trip. - Wide input coverage.
- Randomized round-trips at every length from 0 to 99 for each alphabet variant
- Full-range Unicode code points and surrogate-pair handling for UTF-8
- Per-instance assertions of the exact alphabet string each codec emits, which catch miscopied lookup tables.
- Failure paths are asserted, not assumed. Malformed UTF-8, invalid characters, and exhaustive invalid-length sweeps all verify that a typed error is raised (with the exact message and offset), never a silent wrong result.
- Every platform. The suite runs on the Dart VM, Node.js (JavaScript), and Chrome (WASM) in CI across Dart SDK 2.19 and stable on Linux, macOS, and Windows. Special care has been given for the web, where integers behave differently.
- Regressions stay fixed. Real bugs found in the past (a word-safe Base-32
table accidentally copied from z-base-32, a dropped
& 0x3Fmask in the UTF-8 decoder, aByteCollector.isEqualself-comparison) each have a permanent, externally-anchored regression test, and a differential fuzz harness re-checks the codecs against the reference implementations.
Because correctness is anchored to independent references rather than the
package's own agreement with itself, convertlib is safe to rely on in
production. If you do hit a discrepancy, please open an issue and include
your input and the expected output.
🚀 Benchmarks #
Libraries #
- Convertlib : https://pub.dev/packages/convertlib
- Base Codecs : https://pub.dev/packages/base_codecs
- Base32 : https://pub.dev/packages/base32
- Base X : https://pub.dev/packages/base_x
- Convert : https://pub.dev/packages/convert
- Hex : https://pub.dev/packages/hex
- PointyCastle : https://pub.dev/packages/pointycastle
- Dart Convert : https://api.dart.dev/stable/dart-convert/dart-convert-library.html
UTF-8 throughput is measured per source code point, not per byte. Crypt throughput is measured per character of the hash string. Base-36, Base-58 and Base-62 are quadratic in the input size, so their payload is capped at 1KB.
Encoding #
| Codec | Library | 1MB message | 1KB message | 32B message |
|---|---|---|---|---|
| Base-2 | convertlib | ████████████████ 1.23 Gbps 🌟 |
████████████████ 1.13 Gbps 🌟 |
████████████████ 1.42 Gbps 🌟 |
| Base-8 | convertlib | ████████████████ 2.88 Gbps 🌟 |
████████████████ 3.98 Gbps 🌟 |
████████████████ 3.14 Gbps 🌟 |
| Base-16 | convertlib | ████████████████ 3.5 Gbps 🌟 |
████████████████ 4.24 Gbps 🌟 |
████████████████ 3.39 Gbps 🌟 |
| base_codecs | █░░░░░░░░░░░░░░░ 169 Mbps 🔻20.69x |
█░░░░░░░░░░░░░░░ 156 Mbps 🔻27.13x |
█░░░░░░░░░░░░░░░ 153 Mbps 🔻22.16x |
|
| convert | ███████████████░ 3.35 Gbps 🔻1.05x |
███████████████░ 3.98 Gbps 🔻1.06x |
███████████████░ 3.09 Gbps 🔻1.09x |
|
| hex | █░░░░░░░░░░░░░░░ 140 Mbps 🔻25.08x |
█░░░░░░░░░░░░░░░ 130 Mbps 🔻32.69x |
█░░░░░░░░░░░░░░░ 128 Mbps 🔻26.54x |
|
| Base-32 | convertlib | ████████████████ 3.66 Gbps 🌟 |
████████████████ 4.26 Gbps 🌟 |
████████████████ 3.22 Gbps 🌟 |
| base_codecs | █░░░░░░░░░░░░░░░ 305 Mbps 🔻11.99x |
█░░░░░░░░░░░░░░░ 250 Mbps 🔻17.07x |
█░░░░░░░░░░░░░░░ 219 Mbps 🔻14.67x |
|
| base32 | █░░░░░░░░░░░░░░░ 244 Kbps 🔻14965.61x |
█░░░░░░░░░░░░░░░ 60.23 Mbps 🔻70.74x |
█░░░░░░░░░░░░░░░ 63.16 Mbps 🔻50.96x |
|
| Base-36 | convertlib | ████████████████ 201 Mbps 🌟 |
████████████████ 201 Mbps 🌟 |
████████████████ 1.13 Gbps 🌟 |
| BigInt | █░░░░░░░░░░░░░░░ 5.62 Mbps 🔻35.74x |
█░░░░░░░░░░░░░░░ 5.62 Mbps 🔻35.7x |
█░░░░░░░░░░░░░░░ 20.59 Mbps 🔻54.8x |
|
| Base-45 | convertlib | ████████████████ 4.15 Gbps 🌟 |
████████████████ 4.83 Gbps 🌟 |
████████████████ 3.77 Gbps 🌟 |
| Base-58 | convertlib | ████████████████ 164 Mbps 🌟 |
████████████████ 164 Mbps 🌟 |
████████████████ 1.31 Gbps 🌟 |
| base_codecs | █░░░░░░░░░░░░░░░ 2.39 Mbps 🔻68.7x |
█░░░░░░░░░░░░░░░ 2.39 Mbps 🔻68.82x |
█░░░░░░░░░░░░░░░ 54.77 Mbps 🔻23.86x |
|
| Base-62 | convertlib | ████████████████ 213 Mbps 🌟 |
████████████████ 211 Mbps 🌟 |
████████████████ 1.23 Gbps 🌟 |
| base_x | █░░░░░░░░░░░░░░░ 3.68 Mbps 🔻57.89x |
█░░░░░░░░░░░░░░░ 3.68 Mbps 🔻57.48x |
█░░░░░░░░░░░░░░░ 47.83 Mbps 🔻25.76x |
|
| Base-64 | convertlib | ████████████████ 4.33 Gbps 🌟 |
████████████████ 5.02 Gbps 🌟 |
████████████████ 3.81 Gbps 🌟 |
| dart:convert | █████████████░░░ 3.5 Gbps 🔻1.24x |
█████████████░░░ 3.98 Gbps 🔻1.26x |
████████████░░░░ 2.87 Gbps 🔻1.33x |
|
| Base-85 | convertlib | ████████████████ 4.11 Gbps 🌟 |
████████████████ 4.68 Gbps 🌟 |
████████████████ 3.64 Gbps 🌟 |
| base_codecs | ████████░░░░░░░░ 2.02 Gbps 🔻2.03x |
████████░░░░░░░░ 2.41 Gbps 🔻1.95x |
██████░░░░░░░░░░ 1.26 Gbps 🔻2.9x |
|
| Z85 | convertlib | ████████████████ 4.02 Gbps 🌟 |
████████████████ 4.62 Gbps 🌟 |
████████████████ 3.62 Gbps 🌟 |
| base_codecs | █████████░░░░░░░ 2.35 Gbps 🔻1.71x |
█████████░░░░░░░ 2.62 Gbps 🔻1.76x |
█████████░░░░░░░ 2 Gbps 🔻1.81x |
|
| Bech32 | convertlib | ████████████████ 1.27 Gbps 🌟 |
████████████████ 1.35 Gbps 🌟 |
████████████████ 987 Mbps 🌟 |
| Punycode | convertlib | ████████████████ 773 Mbps 🌟 |
████████████████ 818 Mbps 🌟 |
████████████████ 812 Mbps 🌟 |
| Percent | convertlib | ████████████████ 1.87 Gbps 🌟 |
████████████████ 2.16 Gbps 🌟 |
████████████████ 1.65 Gbps 🌟 |
| dart:core | ████░░░░░░░░░░░░ 470 Mbps 🔻3.98x |
████░░░░░░░░░░░░ 496 Mbps 🔻4.36x |
███░░░░░░░░░░░░░ 339 Mbps 🔻4.88x |
|
| UTF-8 | convertlib | ████████████████ 2.66 Gbps 🌟 |
████████████████ 2.91 Gbps 🌟 |
████████████████ 2.38 Gbps 🌟 |
| dart:convert | ███████████░░░░░ 1.86 Gbps 🔻1.43x |
███████████░░░░░ 1.97 Gbps 🔻1.48x |
███████████░░░░░ 1.65 Gbps 🔻1.44x |
|
| UTF-8 (ASCII) | convertlib | ████████████████ 7.36 Gbps 🌟 |
████████████████ 7.82 Gbps 🌟 |
████████████████ 7.03 Gbps 🌟 |
| dart:convert | ████████░░░░░░░░ 3.77 Gbps 🔻1.95x |
████████░░░░░░░░ 3.87 Gbps 🔻2.02x |
███████░░░░░░░░░ 3.01 Gbps 🔻2.33x |
Decoding #
| Codec | Library | 1MB message | 1KB message | 32B message |
|---|---|---|---|---|
| Base-2 | convertlib | ████████████████ 1.27 Gbps 🌟 |
████████████████ 1.3 Gbps 🌟 |
████████████████ 1.24 Gbps 🌟 |
| Base-8 | convertlib | ████████████████ 3.29 Gbps 🌟 |
████████████████ 3.57 Gbps 🌟 |
████████████████ 3.06 Gbps 🌟 |
| Base-16 | convertlib | ████████████████ 1.55 Gbps 🌟 |
████████████████ 1.84 Gbps 🌟 |
████████████████ 1.53 Gbps 🌟 |
| base_codecs | ██░░░░░░░░░░░░░░ 164 Mbps 🔻9.45x |
█░░░░░░░░░░░░░░░ 165 Mbps 🔻11.17x |
██░░░░░░░░░░░░░░ 162 Mbps 🔻9.46x |
|
| convert | ███████░░░░░░░░░ 658 Mbps 🔻2.35x |
██████░░░░░░░░░░ 687 Mbps 🔻2.68x |
███████░░░░░░░░░ 622 Mbps 🔻2.46x |
|
| hex | ██░░░░░░░░░░░░░░ 155 Mbps 🔻9.98x |
█░░░░░░░░░░░░░░░ 159 Mbps 🔻11.59x |
██░░░░░░░░░░░░░░ 148 Mbps 🔻10.31x |
|
| Base-32 | convertlib | ████████████████ 3.16 Gbps 🌟 |
████████████████ 3.21 Gbps 🌟 |
████████████████ 2.61 Gbps 🌟 |
| base_codecs | █░░░░░░░░░░░░░░░ 188 Mbps 🔻16.82x |
█░░░░░░░░░░░░░░░ 177 Mbps 🔻18.08x |
█░░░░░░░░░░░░░░░ 183 Mbps 🔻14.27x |
|
| base32 | █░░░░░░░░░░░░░░░ 100 Mbps 🔻31.52x |
█░░░░░░░░░░░░░░░ 150 Mbps 🔻21.36x |
█░░░░░░░░░░░░░░░ 118 Mbps 🔻22.12x |
|
| Base-36 | convertlib | ████████████████ 408 Mbps 🌟 |
████████████████ 408 Mbps 🌟 |
████████████████ 1.65 Gbps 🌟 |
| BigInt | █░░░░░░░░░░░░░░░ 27.05 Mbps 🔻15.09x |
█░░░░░░░░░░░░░░░ 27.12 Mbps 🔻15.05x |
█░░░░░░░░░░░░░░░ 46.99 Mbps 🔻35.19x |
|
| Base-45 | convertlib | ████████████████ 3.47 Gbps 🌟 |
████████████████ 3.52 Gbps 🌟 |
████████████████ 3.14 Gbps 🌟 |
| Base-58 | convertlib | ████████████████ 396 Mbps 🌟 |
████████████████ 396 Mbps 🌟 |
████████████████ 1.79 Gbps 🌟 |
| base_codecs | █░░░░░░░░░░░░░░░ 2.34 Mbps 🔻169.21x |
█░░░░░░░░░░░░░░░ 2.34 Mbps 🔻169.15x |
█░░░░░░░░░░░░░░░ 63.61 Mbps 🔻28.22x |
|
| Base-62 | convertlib | ████████████████ 406 Mbps 🌟 |
████████████████ 406 Mbps 🌟 |
████████████████ 1.64 Gbps 🌟 |
| base_x | █░░░░░░░░░░░░░░░ 5.12 Mbps 🔻79.24x |
█░░░░░░░░░░░░░░░ 5.12 Mbps 🔻79.22x |
██░░░░░░░░░░░░░░ 166 Mbps 🔻9.92x |
|
| Base-64 | convertlib | ████████████████ 3.76 Gbps 🌟 |
████████████████ 3.83 Gbps 🌟 |
████████████████ 3.13 Gbps 🌟 |
| dart:convert | █████████░░░░░░░ 2.21 Gbps 🔻1.7x |
█████████░░░░░░░ 2.23 Gbps 🔻1.72x |
█████████░░░░░░░ 1.81 Gbps 🔻1.73x |
|
| Base-85 | convertlib | ████████████████ 4.2 Gbps 🌟 |
████████████████ 4.26 Gbps 🌟 |
████████████████ 3.22 Gbps 🌟 |
| base_codecs | █░░░░░░░░░░░░░░░ 41.18 Mbps 🔻102.1x |
█░░░░░░░░░░░░░░░ 46.58 Mbps 🔻91.49x |
█░░░░░░░░░░░░░░░ 40.55 Mbps 🔻79.46x |
|
| Z85 | convertlib | ████████████████ 4.2 Gbps 🌟 |
████████████████ 4.27 Gbps 🌟 |
████████████████ 3.43 Gbps 🌟 |
| base_codecs | █░░░░░░░░░░░░░░░ 50.99 Mbps 🔻82.43x |
█░░░░░░░░░░░░░░░ 52.13 Mbps 🔻81.97x |
█░░░░░░░░░░░░░░░ 46.71 Mbps 🔻73.36x |
|
| Bech32 | convertlib | ████████████████ 906 Mbps 🌟 |
████████████████ 914 Mbps 🌟 |
████████████████ 710 Mbps 🌟 |
| Punycode | convertlib | ████████████████ 623 Mbps 🌟 |
████████████████ 633 Mbps 🌟 |
████████████████ 667 Mbps 🌟 |
| Percent | convertlib | ████████████████ 1.55 Gbps 🌟 |
████████████████ 1.64 Gbps 🌟 |
████████████████ 1.34 Gbps 🌟 |
| dart:core | ██░░░░░░░░░░░░░░ 218 Mbps 🔻7.14x |
████░░░░░░░░░░░░ 439 Mbps 🔻3.74x |
█████░░░░░░░░░░░ 396 Mbps 🔻3.39x |
|
| UTF-8 | convertlib | ████████████████ 1.34 Gbps 🌟 |
████████████████ 1.41 Gbps 🌟 |
████████████░░░░ 923 Mbps |
| dart:convert | █████████████░░░ 1.12 Gbps 🔻1.2x |
███████████████░ 1.32 Gbps 🔻1.06x |
████████████████ 1.21 Gbps 🔺1.31x |
|
| UTF-8 (ASCII) | convertlib | ████████████████ 35.31 Gbps |
████████████████ 82.4 Gbps 🌟 |
████████████░░░░ 8.8 Gbps |
| dart:convert | ████████████████ 35.57 Gbps 🔺1.01x |
███████████████░ 78.09 Gbps 🔻1.06x |
████████████████ 11.3 Gbps 🔺1.28x |
BigInt #
| Codec | Library | 4KB message | 256B message | 32B message |
|---|---|---|---|---|
| bytes → BigInt | convertlib | ████████████████ 494 Mbps 🌟 |
████████████████ 568 Mbps 🌟 |
████████████████ 660 Mbps 🌟 |
| hex + BigInt.parse | ██████░░░░░░░░░░ 200 Mbps 🔻2.48x |
█████░░░░░░░░░░░ 183 Mbps 🔻3.1x |
██░░░░░░░░░░░░░░ 93.96 Mbps 🔻7.02x |
|
| pointycastle | █░░░░░░░░░░░░░░░ 12.42 Mbps 🔻39.82x |
███░░░░░░░░░░░░░ 101 Mbps 🔻5.63x |
█████░░░░░░░░░░░ 193 Mbps 🔻3.42x |
|
| BigInt → bytes | convertlib | ████████████████ 139 Mbps 🌟 |
██████████░░░░░░ 137 Mbps |
███████░░░░░░░░░ 126 Mbps |
| toRadixString + fromHex | ████████████████ 139 Mbps 🔻1x |
██████████░░░░░░ 136 Mbps 🔻1x |
███████░░░░░░░░░ 125 Mbps 🔻1.01x |
|
| pointycastle | ████░░░░░░░░░░░░ 38.61 Mbps 🔻3.61x |
████████████████ 224 Mbps 🔺1.64x |
████████████████ 293 Mbps 🔺2.33x |
Crypt #
| Codec | Library | argon2id (96 chars) | bcrypt (60 chars) |
|---|---|---|---|
| fromCrypt | convertlib | ████████████████ 999 Mbps 🌟 |
████████████████ 1.39 Gbps 🌟 |
| toCrypt | convertlib | ████████████████ 660 Mbps 🌟 |
████████████████ 1.12 Gbps 🌟 |
All benchmarks are done on AMD Ryzen 7 5800X CPU + 3200MHz RAM using compiled exe
Dart SDK version: 3.14.0 (stable) (Wed Nov 4 16:28:39 2026 -0800) on "windows_x64"
📄 License #
BSD 3-Clause License. See the LICENSE file for details. Issues and contributions are welcome at github.com/bitanon/convertlib.