Ejemplo n.º 1
0
 /**
  * Uses an instance of `MD5`, `SHA1` or `PBKDF2` to create a hash
  *
  * @see cryptography.MD5#hash()
  * @see cryptography.SHA1#hash()
  * @see cryptography.PBKDF2#hash()
  *
  * @param string $input
  * the string to be hashed
  * @param string $algorithm
  * a handle for the algorithm to be used
  * @deprecated This parameter will be removed in a future release. The use of i.e. `SHA1::hash()` is recommended instead when not using the default algorithm.
  * @return string
  * the hashed string
  */
 public static function hash($input, $algorithm = 'pbkdf2')
 {
     switch ($algorithm) {
         case 'md5':
             return MD5::hash($input);
             break;
         case 'sha1':
             return SHA1::hash($input);
             break;
         case 'pbkdf2':
         default:
             return PBKDF2::hash($input);
             break;
     }
 }
Ejemplo n.º 2
0
 /**
  * Uses `SHA1` or `MD5` to create a hash based on some input
  * This function is currently very basic, but would allow
  * future expansion. Salting the hash comes to mind.
  *
  * @param string $input
  *  the string to be hashed
  * @param string $algorithm
  *  This function supports 'md5', 'sha1' and 'pbkdf2'. Any
  *  other algorithm will default to 'pbkdf2'.
  * @return string
  *  the hashed string
  */
 public static function hash($input, $algorithm = 'sha1')
 {
     switch ($algorithm) {
         case 'sha1':
             return SHA1::hash($input);
         case 'md5':
             return MD5::hash($input);
         case 'pbkdf2':
         default:
             return Crytography::hash($input, $algorithm);
     }
 }