*/
function calculateSumFromHash ($hash) {
// Everything starts with zero ...
+ //* NOISY-DEBUG: */ printf('[%s:%d]: hash(%d)=%s - CALLED!'. PHP_EOL, __FUNCTION__, __LINE__, strlen($hash), $hash);
$sum = 0;
+ // Part of the hash is not decodeable
+ $decodeA = explode('$', $hash);
+ $decode = $decodeA[4];
+
// Loop through hash
- for ($idx = 0; $idx < (strlen($hash) / 2); $idx++) {
+ //* NOISY-DEBUG: */ printf('[%s:%d]: decode=%s' . PHP_EOL, __FUNCTION__, __LINE__, $decode);
+ for ($idx = 0; $idx < (strlen($decode) / 2); $idx++) {
// And add it
- $sum = $sum + hexdec(substr($hash, $idx, 2));
+ $sum = $sum + hexdec(substr($decode, $idx, 2));
} // END - for
// And return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: sum=%d - EXIT!' . PHP_EOL, __FUNCTION__, __LINE__, $sum);
return $sum;
}