Cotton code
25 lines · 913 B · SwiftRaw
// The fixed hash a slug or a record id is folded through — hashing, not look.//// Moved out of `Paper/ProjectCaps.swift` so the paper's files carry only the// theme's numbers. It picks WHICH enamel, dye or noise stream a thing gets,// never how anything is drawn; changing it re-deals every cap on every board,// so it is fixed in code and never a theme knob.import Foundationenum StableHash {    /// FNV-1a's 64-bit offset basis and prime.    static let offsetBasis: UInt64 = 0xcbf2_9ce4_8422_2325    static let prime: UInt64 = 0x0000_0100_0000_01b3    /// FNV-1a over the text's UTF-8 — the same number on every launch and    /// every device, which `Hasher` is not.    public static func fnv1a(_ text: String) -> UInt64 {        var hash = offsetBasis        for byte in text.utf8 {            hash ^= UInt64(byte)            hash = hash &* prime        }        return hash    }}