passwordHash

passwordHash class

Portable PHP hashing system. Creates more secure hashes of data e.g. for passwords. A very basic example is below. passwordHash is used in systemUser.

// for password checking
$password = 'my secret pass';
$hash = passwordHash::HashPassword($password);

// store hash in DB

// compare user supplied hash to that already generated
$storedHash = Class::getUserHash(); // replace with your function

if ( passwordHash::CheckPassword($suppliedPassword, $storedHash) {
    echo "OK you are logged in";
} else {
    echo "Not valid";
}

Methods

public __construct($iteration_count_log2, $portable_hashes)

Returns new instance of passwordHash

public static getInstance([$inIterations = 8], [$inPortableHashes = false])

Returns an instance of the passwordHash object

public setIterations($inIterations)

Set the iteration count to $inIterations, must be >4 but <31

public setPortableHashes($inStatus)

Set whether to use portable hashes (true) or not (false)

public get_random_bytes($count)

Get random data from /dev/random

public encode64($input, $count)

Encode a string into a 64 bit string

public gensalt_private($input)

Generate a private salt

public crypt_private($password, $setting)

Encrypt the string

public gensalt_extended($input)

Generate a salt

public gensalt_blowfish($input)

Generate a blowfish salt

public HashPassword($password)

Make a hash of the password

public CheckPassword($password, $stored_hash)

Validates that the supplied password matches the stored hash

<  1  >