original_string: public static function hash($string, $algorithm = null, $salt = false)
      {
          if (empty($algorithm)) {
              $algorithm = static::$hashType;
          }
          $algorithm = strtolower($algorithm);
  
          $availableAlgorithms = hash_algos();
          if (!in_array($algorithm, $availableAlgorithms)) {
              throw new RuntimeException(sprintf(
                  'The hash type `%s` was not found. Available algorithms are: %s',
                  $algorithm,
                  implode(', ', $availableAlgorithms)
              ));
          }
  
          if ($salt) {
              if (!is_string($salt)) {
                  $salt = static::$_salt;
              }
              $string = $salt . $string;
          }
  
          return hash($algorithm, $string);
      }
code: public static function hash($string, $algorithm = null, $salt = false)
      {
          if (empty($algorithm)) {
              $algorithm = static::$hashType;
          }
          $algorithm = strtolower($algorithm);
  
          $availableAlgorithms = hash_algos();
          if (!in_array($algorithm, $availableAlgorithms)) {
              throw new RuntimeException(sprintf(
                  'The hash type `%s` was not found. Available algorithms are: %s',
                  $algorithm,
                  implode(', ', $availableAlgorithms)
              ));
          }
  
          if ($salt) {
              if (!is_string($salt)) {
                  $salt = static::$_salt;
              }
              $string = $salt . $string;
          }
  
          return hash($algorithm, $string);
      }
code_tokens: public static function hash ( $ string , $ algorithm = null , $ salt = false ) { if ( empty ( $ algorithm ) ) { $ algorithm = static :: $ hashType ; } $ algorithm = strtolower ( $ algorithm ) ; $ availableAlgorithms = hash_algos ( ) ; if ( ! in_array ( $ algorithm , $ availableAlgorithms ) ) { throw new RuntimeException ( sprintf ( 'The hash type `%s` was not found. Available algorithms are: %s' , $ algorithm , implode ( ', ' , $ availableAlgorithms ) ) ) ; } if ( $ salt ) { if ( ! is_string ( $ salt ) ) { $ salt = static :: $ _salt ; } $ string = $ salt . $ string ; } return hash ( $ algorithm , $ string ) ; }
docstring: Create a hash from string using given method.
  
  @param string $string String to hash
  @param string|null $algorithm Hashing algo to use (i.e. sha1, sha256 etc.).
  Can be any valid algo included in list returned by hash_algos().
  If no value is passed the type specified by `Security::$hashType` is used.
  @param mixed $salt If true, automatically prepends the application's salt
  value to $string (Security.salt).
  @return string Hash
  @link https://book.cakephp.org/3.0/en/core-libraries/security.html#hashing-data
docstring_tokens: Create a hash from string using given method .