# Copyright (c) 2026-present, the Ladybird developers. # # SPDX-License-Identifier: BSD-2-Clause def string_hash(string: str) -> int: """Port of AK::string_hash that produces the same u32 value.""" h = 0 for ch in string: h = (h + ord(ch)) & 0xFFFFFFFF h = (h + (h << 10)) & 0xFFFFFFFF h ^= h >> 6 h = (h + (h << 3)) & 0xFFFFFFFF h ^= h >> 11 h = (h + (h << 15)) & 0xFFFFFFFF return h