hash() public static method

Configurable hash() algorithm (defaults to md5)
public static hash ( string $str, boolean $raw_output = false ) : string
$str string String to be hashed
$raw_output boolean
return string Hash string
Example #1
0
 /**
  * Generate hash on user info and password
  *
  * @param string $userInfo User name, email, etc
  * @param string $password
  * @return string
  */
 private function generateHash($userInfo, $password)
 {
     // mitigate rainbow table attack
     $passwordLen = strlen($password) / 2;
     $hash = Common::hash($userInfo . substr($password, 0, $passwordLen) . SettingsPiwik::getSalt() . substr($password, $passwordLen));
     return $hash;
 }
Example #2
0
 private function generateCommandId($command)
 {
     return substr(Common::hash($command . microtime(true) . rand(0, 99999)), 0, 100);
 }
 /**
  * Hashes a string. By default generates an MD5 hash.
  *
  * Derived classes can override this to provide a different hashing implementation.
  *
  * @param string $data The data to hash.
  * @return string
  */
 protected function hashData($data)
 {
     return Common::hash($data);
 }