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/20fde1db2aa96410c0c0b6a32494ad98 to your computer and use it in GitHub Desktop.

Select an option

Save zatricky/20fde1db2aa96410c0c0b6a32494ad98 to your computer and use it in GitHub Desktop.
Stationeers hash function for Powershell using python's CRC32 function and BitConverter
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <https://unlicense.org>
function Get-IC10Hash {
<#
.SYNOPSIS
Generate IC10 hash values for Stationeers game objects.
.DESCRIPTION
Converts a text string to an IC10 hash value (signed 32-bit CRC32) and its hex notation.
The hex notation is compatible with IC10's $ hex literal format.
.PARAMETER Text
The text string to hash (e.g., "StructureGasAnalyser")
Can also accept pipeline input.
.EXAMPLE
Get-IC10Hash "StructureGasAnalyser"
Text Hash Hex
---- ---- ---
StructureGasAnalyser 1876147318 $6FD3BC76
.EXAMPLE
Get-IC10Hash "StructureLiquidAnalyser"
Text Hash Hex
---- ---- ---
StructureLiquidAnalyser -1789102802 $FFFFFFFF955C752E
.EXAMPLE
"StructureGasAnalyser", "StructureLiquidAnalyser" | Get-IC10Hash
Text Hash Hex
---- ---- ---
StructureGasAnalyser 1876147318 $6FD3BC76
StructureLiquidAnalyser -1789102802 $FFFFFFFF955C752E
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
[string]$Text
)
Process {
# Use Python's zlib.crc32 for cross-platform CRC32 calculation
$pythonScript = @"
import zlib
import sys
text = sys.argv[1]
crc32 = zlib.crc32(text.encode('utf-8')) & 0xFFFFFFFF
print(crc32)
"@
$crc32 = [uint32](python3 -c $pythonScript $Text)
# Convert to signed 32-bit integer using BitConverter
# This properly reinterprets the bytes without arithmetic conversion
$crcBytes = [BitConverter]::GetBytes($crc32)
$hashValue = [BitConverter]::ToInt32($crcBytes, 0)
# Generate hex notation
if ($hashValue -lt 0) {
# Negative: use 64-bit two's complement (16 hex digits)
# For negatives, prepend FFFFFFFF to the unsigned 32-bit CRC hex
$hexValue = '$FFFFFFFF' + $crc32.ToString("X8")
} else {
# Positive: compact format (strip leading zeros)
$hexValue = '$' + $crc32.ToString("X")
}
# Output as custom object for better formatting
[PSCustomObject]@{
Text = $Text
Hash = $hashValue
Hex = $hexValue
}
}
}
# Create alias for shorter usage
# Set-Alias -Name ic10hash -Value Get-IC10Hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment