Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash length #5

Open
NicoHood opened this issue Dec 29, 2020 · 0 comments
Open

Hash length #5

NicoHood opened this issue Dec 29, 2020 · 0 comments

Comments

@NicoHood
Copy link

Hi,
I did not try your code, but looking at it helped me for my project (thanks). I am wondering if the hash function wouldnt make more sense to always return 10 digits. Sometimes it returns 9 or 11:
https://github.com/aelvan/Stamp-Craft/blob/craft3/src/variables/StampVariable.php#L76

This is my current solution to this:

private function num_hash_file($filePath)
{
    $crc = implode(unpack('C*', hash_file('crc32b', $filePath, true)));
    return substr(str_pad($crc, 10, '0', STR_PAD_LEFT), 0, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant