Skip to content

Petrichor.Hash#

require("Petrichor.Hash") exposes MD5 and SHA-256 in pure Luau.

Hash.hashSeed(seedStr, isRaceSeed) → number#

Hashes a seed name into a signed 32-bit integer. Normal seeds use MD5. Race seeds use SHA-256 with a fixed salt. The return value is the first four digest bytes interpreted as little-endian i32.

local Hash = require("Petrichor.Hash")

local normal = Hash.hashSeed("MySeedName", false)
local race = Hash.hashSeed("MySeedName", true)
import * as Hash from "Petrichor.Hash"

const normal = Hash.hashSeed("MySeedName", false)
const race = Hash.hashSeed("MySeedName", true)

Lower-level helpers Hash.md5Bytes(message) and Hash.sha256Bytes(message) return byte arrays when you need the raw digest.