hasher = new PasswordHash( 8, false ); $this->salt = $config->get_salt(); } /** * Compute hash. * * @param string $input Input to compute hash. * @return string */ public function hash( $input ) { return $this->hasher->HashPassword( $input . $this->salt ); } /** * Check hash. * * @param string $input Intput that has hash computed. * @param string $hash Computed hash. * @return bool */ public function check( $input, $hash ) { return $this->hasher->CheckPassword( $input . $this->salt, $hash ); } /** * Check hash and return original value if valid. Null otherwise. * * @param string $input Intput that has hash computed. * @param string $hash Computed hash. * @return string|null */ public function return_if_valid( $input, $hash ) { if ( $this->check( $input, $hash ) ) { return $input; } else { return null; } } }