-// Hashes per call
-$GLOBALS['cycles'] = 3;
-
-// Found hashes
-$GLOBALS['found_hashes'] = array(0 => array());
-
-/**
- * Continued-hashing
- *
- * @author Roland Haeder <roland@mxchange.org>
- * @copyright Copyright (c) 2013 by Core Developer Team
- * @license See LICENSE (public-domain)
- */
-
-/**
- * Calculates a simple but stronger hash from given string. No salts are being
- * added here.
- *
- * @param $str The string to be hashed
- * @return $hash The hash from string $str
- */
-function hashString ($str) {
- // Calculate strong hash from given string
- $hash = mhash(HASH_ALGO, $str);
-
- // Return it hexadecimal-encoded
- return bin2hex($hash);
-}
-
-/**
- * Multiple-hashes given string. This is done by hashing the given string and
- * then hashing the generated hash again.
- *
- * @param $str The string to be hashed 4 times
- * @return $hash The generated hash
- */
-function multipleHashString ($str) {
- // One less to go (see below)
- $totalHashes = $GLOBALS['cycles'] - 1;
-
- // Generate hash from given hash
- $hash = hashString($str);
-
- // Now over-hash it
- for ($idx = 0; $idx < $totalHashes; $idx++) {
- // Over-hash the given hash
- $hash = hashString($hash . $str);
- } // END - for
-
- // Return it
- return $hash;
-}
-
-/**
- * Calculates a "modula-hash" based given two hashes.
- *
- * @param $hash1 Hash 1
- * @param $hash2 Hash 2
- */
-function modulaHash ($hash1, $hash2) {
- // Both must have same length
- assert(strlen($hash1) === strlen($hash2));
-
- // Init new hash
- $modulaHash = '';
-
- // "Walk" trough first hash and get every 2 byte of both hashes
- for ($idx = 0; $idx < strlen($hash1); $idx += 2) {
- // Init modula value
- $mod = 0;
-
- // Get both hash parts and convert to ASCII number
- $part1 = hexdec(substr($hash1, $idx, 2));
- $part2 = hexdec(substr($hash2, $idx, 2));
-
- /*
- * If part1 is larget part2, part1 is divident and vise-versa. But don't do it
- * if one is zero
- */
- if (($part1 > $part2) && ($part2 > 0)) {
- // 'part1' is larger than 'part2'
- $mod = $part1 % $part2;
- } elseif (($part1 < $part2) && ($part1 > 0)) {
- // 'part2' is larger than 'part1'
- $mod = $part2 % $part1;
- }
-
- // "Invert" the result against 255
- $mod = 255 - $mod;
-
- // Encode to hex, pre-pad it with zeros and add to new hash
- $modulaHash .= padHex($mod);
- } // END - for
-
- // Modula hash must have same length as input hash
- assert(strlen($modulaHash) === strlen($hash1));
-
- // Return modula hash
- return $modulaHash;
-}
-
-/**
- * Calculates a "sqrt-hash" based given two hashes and single-hash it
- *
- * @param $hash1 Hash 1
- * @param $hash2 Hash 2
- */
-function sqrtHash ($hash1, $hash2) {
- // Both must have same length
- assert(strlen($hash1) === strlen($hash2));
-
- // Init new hash
- $sqrtHash = '';