-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_otp.php
More file actions
37 lines (27 loc) · 765 Bytes
/
Copy pathtest_otp.php
File metadata and controls
37 lines (27 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include 'php-otp.php';
include 'PhpEntropy.php';
include 'PassHash.php';
echo '<h3>Generating 10 random passwords</h3>';
$otp = new phpotp();
$passes = $otp->passwords('bah',10,32);
echo 'Total: '. count($passes) . '<br>';
echo 'Unique: '. count(array_unique($passes)). '<br><br>';
echo '<pre>';
print_r($passes);
echo '</pre>';
echo '<h3>Hashing password with secret: "foo"</h3>';
$hashes = $otp->hashPasswords('foo', $passes);
echo '<pre>';
print_r($hashes);
echo '</pre>';
echo '<h3>Check if hashes match "foo".$password</h3>';
$ph = new PassHash();
$checks = array();
foreach($passes as $n => $pass) {
$checks[$n] = ($ph->CheckPassword('foo'.$pass, $hashes[$n]) === false) ? 'false' : 'true';
}
echo '<pre>';
print_r($checks);
echo '</pre>';
?>