Justin's Words

PHPass 用法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
#
# http://www.openwall.com/phpass/
# http://sunnyis.me/blog/secure-passwords/
#

requeir("PasswordHash.php");

## Creating the Hash
$password = $_REQUEST['password'];

$hasher = new PasswordHash(8, false);
$hash = $header->HashPassword($password); // you can store the hash somewhere such as database

## Checking "Matched" Passwords
$password = $_REQUEST['password'];

$hasher = new PasswordHash(8, false);
$stored_hash = "this is the hash we stored ealier";

$check = $hasher->CheckPassword($password, $stored_hash); // return true if match or false if not match

?>