hashlib_codecs 3.0.1

SDKdartflutter
Platformandroidioswindowslinuxmacosweb

Fast and error resilient codecs. Currently supporting Binary(Base2), Hexadecimal(Base16), Base32, Base64, BigInt.

Hashlib Codecs

plugin version test codecov likes pub points popularity dart support dependencies

This library contains implementations of fast and error resilient codecs in pure Dart.

Depencencies

This package has NO dependency.

Features

Binary (Base-2)

TypeAvailable
ClassBase2Codec
MethodsfromBinary, toBinary

Available codecs:

  • standard: 01 (default)

Octal (Base-8)

TypeAvailable
ClassBase8Codec
MethodsfromOctal, toOctal

Available codecs:

  • standard: 012345678 (default)

Hexadecimal (Base-16)

TypeAvailable
ClassBase16Codec
MethodsfromHex, toHex

Available codecs:

  • upper: 0123456789ABCDEF (default)
  • lower: 0123456789abcdef

Base-32

Supports conversion without padding

TypeAvailable
ClassBase32Codec
MethodsfromBase32, 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.

TypeAvailable
ClassBase64Codec
MethodsfromBase64, toBase64

Available codecs:

  • standard (RFC-4648): ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ (default)
  • urlSafe: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
  • bcrypt: ./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789

UTF-8

TypeAvailable
ClassUTF8Codec
MethodsfromUtf8, toUtf8

Available codecs:

BigInt

Supports both the Big-Endian and Little-Endian conversion

TypeAvailable
ClassBigIntCodec
MethodsfromBigInt, 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.

TypeAvailable
ClassCryptFormat
Constantcrypt
MethodstoCrypt, 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('');
}