Beispiel #1
0
 /**
  * Generates a hashing key for further repeatable hashes.
  *
  * @param int $length Length of the key being generated for hashing.
  * @return string
  * @throws Exceptions\InvalidTypeException
  * @throws Exceptions\OutOfRangeException
  */
 public static function generateKey($length = Constants::GENERICHASH_KEYBYTES)
 {
     # Test the length for validity.
     Helpers::rangeCheck($length, Constants::GENERICHASH_KEYBYTES_MAX, Constants::GENERICHASH_KEYBYTES_MIN, 'Hash', 'generateKey');
     # Return the hash to the client.
     return self::hash(Entropy::bytes($length), '', $length);
 }
Beispiel #2
0
 /**
  * Returns a secure generated signing key to be used for messages.
  *
  * @return string
  * @throws Exceptions\InvalidTypeException
  * @throws Exceptions\OutOfRangeException
  */
 public static function generateSigningKey()
 {
     return Entropy::bytes(Constants::AUTH_KEYBYTES);
 }