def php_crc32(a):
    """
    References:
    - https://www.php.net/manual/en/function.hash-file.php#104836
    - https://stackoverflow.com/a/50843127/636849
    """
    crc = 0xFFFFFFFF
    for x in a:
        crc ^= x << 24
        for k in range(8):
            crc = (crc << 1) ^ 0x04C11DB7 if crc & 0x80000000 else crc << 1
    crc = ~crc
    crc &= 0xFFFFFFFF
    # Convert from big endian to little endian:
    return int.from_bytes(crc.to_bytes(4, "big"), "little")