Skip to content

Instantly share code, notes, and snippets.

@zatricky
Last active December 23, 2025 13:59
Show Gist options
  • Select an option

  • Save zatricky/f50ce23851d428fe931dd519ab156e56 to your computer and use it in GitHub Desktop.

Select an option

Save zatricky/f50ce23851d428fe931dd519ab156e56 to your computer and use it in GitHub Desktop.
Stationeers hash function for bash using python and zlib
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <https://unlicense.org>
stationeers.hash() {
python3 -c "
import zlib
def ic10_hash(text):
crc32 = zlib.crc32(text.encode('utf-8')) & 0xFFFFFFFF
return crc32 if crc32 < 0x80000000 else crc32 - 0x100000000
def ic10_hex(value):
if value < 0:
unsigned_64 = value & 0xFFFFFFFFFFFFFFFF
return f'\${unsigned_64:016X}'
else:
return f'\${value:X}'
hash_val = ic10_hash('$1')
print(ic10_hex(hash_val))
print(hash_val)
"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment