hashlib_codecs 3.0.1
Fast and error resilient codecs. Currently supporting Binary(Base2), Hexadecimal(Base16), Base32, Base64, BigInt.
Hashlib Codecs
This library contains implementations of fast and error resilient codecs in pure Dart.
Depencencies
This package has NO dependency.
Features
Binary (Base-2)
| Type | Available |
|---|---|
| Class | Base2Codec |
| Methods | fromBinary, toBinary |
Available codecs:
- standard:
01(default)
Octal (Base-8)
| Type | Available |
|---|---|
| Class | Base8Codec |
| Methods | fromOctal, toOctal |
Available codecs:
- standard:
012345678(default)
Hexadecimal (Base-16)
| Type | Available |
|---|---|
| Class | Base16Codec |
| Methods | fromHex, toHex |
Available codecs:
- upper:
0123456789ABCDEF(default) - lower:
0123456789abcdef
Base-32
Supports conversion without padding
| Type | Available |
|---|---|
| Class | Base32Codec |
| Methods | fromBase32, toBase32 |
Available codecs:
- standard (RFC-4648):
ABCDEFGHIJKLMNOPQRSTUVWXYZ234567(default) - lowercase:
abcdefghijklmnopqrstuvwxyz234567 - hex:
0123456789ABCDEFGHIJKLMNOPQRSTUV - hexLower:
0123456789abcdefghijklmnopqrstuv - crockford:
0123456789bcdefghjkmnpqrstuvwxyz - z:
ybndrfg8ejkmcpqxot1uwisza345h769 - wordSafe:
23456789CFGHJMPQRVWXcfghjmpqrvwx
Base-64
Supports conversion without padding, and
the URL/Filename-safe Base64 conversion.
| Type | Available |
|---|---|
| Class | Base64Codec |
| Methods | fromBase64, toBase64 |
Available codecs:
- standard (RFC-4648):
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/(default) - urlSafe:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_ - bcrypt:
./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
UTF-8
| Type | Available |
|---|---|
| Class | UTF8Codec |
| Methods | fromUtf8, toUtf8 |
Available codecs:
- standard: RFC-3629
BigInt
Supports both the Big-Endian and Little-Endian conversion
| Type | Available |
|---|---|
| Class | BigIntCodec |
| Methods | fromBigInt, toBigInt |
Available codecs:
- msbFirst: treats the input bytes in big-endian order
- lsbFirst: treats the input bytes in little-endian order
Modular Crypt Format (PHC String Format)
Encoding and Decoding of Hash algorithm output according to the PHC string format specification.
| Type | Available |
|---|---|
| Class | CryptFormat |
| Constant | crypt |
| Methods | toCrypt, fromCrypt |
Getting Started
The following import will give you access to all of the algorithms in this package.
import 'package:hashlib_codecs/hashlib_codecs.dart';
Check the API Reference for details.
Usage
Examples can be found inside the example folder.
import 'package:hashlib_codecs/hashlib_codecs.dart';
void main() {
var inp = [0x3, 0xF1];
print("input => $inp");
print('');
print("binary => ${toBinary(inp)}");
print('');
print("octal => ${toOctal(inp)}");
print('');
print("hexadecimal => ${toHex(inp)}");
print("hexadecimal (uppercase) => ${toHex(inp, upper: true)}");
print('');
print("base32 => ${toBase32(inp)}");
print("base32 (lowercase) => ${toBase32(inp, lower: true)}");
print("base32 (no padding) => ${toBase32(inp, padding: false)}");
print("base32 (hex) => ${toBase32(inp, codec: Base32Codec.hex)}");
print("base32 (z-base-32) => ${toBase32(inp, codec: Base32Codec.z)}");
print("base32 (geohash) => ${toBase32(inp, codec: Base32Codec.geohash)}");
print("base32 (crockford) => ${toBase32(inp, codec: Base32Codec.crockford)}");
print("base32 (word-safe) => ${toBase32(inp, codec: Base32Codec.wordSafe)}");
print('');
print("base64 => ${toBase64(inp)}");
print("base64url => ${toBase64(inp, url: true)}");
print("base64 (no padding) => ${toBase64(inp, padding: false)}");
print("bcrypt => ${toBase64(inp, codec: Base64Codec.bcrypt)}");
print('');
}