Home > PHP > Function > Mhash > mhash_keygen_s2k()

mhash_keygen_s2k()

mhash_keygen_s2k - Generates a key

Syntax

string mhash_keygen_s2k (int $hash, string $password, string $salt, int $bytes)

Arguments

  • hash - The hash id used to create the key. One of the MHASH_XXXconstants.
  • password - User supplied password.
  • salt - Must be different and random enough for every key you generate in order to create different keys. That salt must be known when you check the keys, thus it is a good idea to append the key to it. Salt has a fixed length of 8 bytes and will be padded with zeros if you supply less bytes.
  • bytes - The key length, in bytes.

Description

Generates a key according to the hash given a user provided password.

Version

PHP 4.0.4, 5

Return value

Returns the generated key as a string, or FALSE on error.