🎉 initial commit

This commit is contained in:
2024-10-07 22:58:27 +02:00
commit d3eccf99f0
824 changed files with 16401 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace Application\Helper;
class NumberHash
{
/**
* Return a number only hash
*
* @see https://stackoverflow.com/a/23679870/175071
*
* @param string $string string to hash
* @param null|int $length optional specific length
*
* @return int
*/
public static function numHash(string $string, ?int $length = null): int
{
$stringHash = md5($string, true);
$numberHash = unpack('N2', $stringHash);
$hash = $numberHash[1] . $numberHash[2];
if ($length) {
$hash = substr($hash, 0, $length);
}
return (int)$hash;
}
}