Skip to content

xxh3 hash ignores seed if string? #10305

Closed
@lolli42

Description

@lolli42

Description

The following code:

<?php
var_dump(hash('xxh3', 'foo'));
# same hash?
var_dump(hash('xxh3', 'foo', options: ['seed' => 'mySeed']));
# different hash!
var_dump(hash('xxh3', 'foo', options: ['seed' => 42]));

Resulted in this output:

string(16) "ab6e5f64077e7d8a"
string(16) "ab6e5f64077e7d8a"
string(16) "d33da54e20ebf99e"

I'd expect the second hash to be different from the first one, just like the third hash. It seems a string as 'seed' is ignored. In case this is intended, it might be good to document this, or maybe except on string non-int input?

PHP Version

Tested with PHP 8.1.13 & 8.2.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions