The heart of BaseHash¶
BaseHash Constants¶
The two constants of BaseHash are HASH_LENGTH
and GENERATOR
.
HASH_LENGTH
, default set to 6
, is used as a default hashing length,
which can be overridden in baseN.hash()
.
GENERATOR
uses the Golden Ratio, 1.618033988749894848
, to determine
the next highest prime, which is based on base ^ length - 1
. GENERATOR
can either be overridden globally or can be overridden within base_hash
or
base_unhash
.
prime¶
-
prime
(base, n, gen) Returns next highest prime. using base^n * gen.
base_decode¶
-
base_decode
(key, alphabet)¶ Decodes string
key
from stringalphabet
(orbase
). Returnsint
base_hash¶
-
base_hash
(num, length, alphabet[, gen=GENERATOR])¶ Hashes int
num
to stringalphabet
(orbase
), intlength
digits long using the built inbase.GENERATOR
, which can be overridden. Returnsstring