Files
jsix_import/scripts/fnv.py
Justin C. Miller 6f7dd7fc05 [boot] More initrd format changes
CDB seemed to be too simple for the needs of init, and squashfs is too
laden with design choices to work around Linux's APIs. This commit adds
creation of an initrd image of a new format I've called `j6romfs`.

Note that this commit currently does not work! The initrd-reading code
still needs to be added.
2023-01-29 19:10:12 -08:00

18 lines
460 B
Python

"""Python implementation of FNV hashes."""
_FNV1_prime32 = 16777619
_FNV1_prime64 = 1099511628211
_FNV1_offset32 = 2166136261
_FNV1_offset64 = 14695981039346656037
def _fnv1a(offset, prime, mask):
def hashfunc(data):
h = offset
for b in data:
h = ((h ^ b) * prime) & mask
return h
return hashfunc
hash64 = _fnv1a(_FNV1_offset64, _FNV1_prime64, (2**64)-1)
hash32 = _fnv1a(_FNV1_offset32, _FNV1_prime32, (2**32)-1)