HashIds class

A Dart class to generate YouTube-like hashes from one or many numbers. {@tool sample}

The simplest use case:

final hashids = HashIds();
final fromNumber = hashids.encode(42);
final number = hashids.decode(fromNumber); // [42]

{@end-tool}

Constructors

HashIds({String salt = DEFAULT_SALT, int minHashLength = DEFAULT_MIN_HASH_LENGTH, String alphabet = DEFAULT_ALPHABET})

Properties

alphabet String
getter/setter pair
guards String
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
minHashLength int
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
salt String
getter/setter pair
seps String
getter/setter pair

Methods

decode(String hash) List<int>
Decodes hasn into list of ints
decodeHex(String hash) String
Decode string to numbers
encode(dynamic number) String
Encodes int, String (with int), or list of ints
encodeHex(String hex) String
Encode hex to string
encodeInt(int number) String
Encode single int
encodeList(List<int> numbers) String
Encode list of numbers
encodeString(String number) String
Encode string with number
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

DEFAULT_ALPHABET → const String
DEFAULT_MIN_HASH_LENGTH → const int
DEFAULT_SALT → const String
DEFAULT_SEPS → const String
GUARD_DIV → const int
MAX_NUMBER → const int
Max number that can be encoded with Hashids.
MIN_ALPHABET_LENGTH → const int
SEP_DIV → const double