This repository was archived by the owner on Oct 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathHashTest.php
More file actions
69 lines (54 loc) · 1.68 KB
/
HashTest.php
File metadata and controls
69 lines (54 loc) · 1.68 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
class HashTest extends PHPUnit_Framework_TestCase {
/**
* Test the creation of the default hash (PBKDF2)
*/
public function testDefaultHash() {
$psl = new \phpSec\Core();
$hash = $psl['crypt/hash'];
$str = 'some string';
$pwHash = $hash->create($str);
$this->assertTrue($hash->check($str, $pwHash));
$this->assertFalse($hash->check($str.'f00', $pwHash));
}
public function testPbkdf2Hash()
{
$psl = new \phpSec\Core();
$hash = $psl['crypt/hash'];
$hash->method = \phpSec\Crypt\Hash::PBKDF2;
$str = 'some string';
$pwHash = $hash->create($str);
$this->assertTrue($hash->check($str, $pwHash));
$this->assertFalse($hash->check($str.'f00', $pwHash));
}
public function testDrupalHash()
{
$psl = new \phpSec\Core();
$hash = $psl['crypt/hash'];
$hash->method = \phpSec\Crypt\Hash::DRUPAL;
$str = 'some string';
$pwHash = $hash->create($str);
$this->assertTrue($hash->check($str, $pwHash));
$this->assertFalse($hash->check($str.'f00', $pwHash));
}
public function testSha256Hash()
{
$psl = new \phpSec\Core();
$hash = $psl['crypt/hash'];
$hash->method = \phpSec\Crypt\Hash::SHA256;
$str = 'some string';
$pwHash = $hash->create($str);
$this->assertTrue($hash->check($str, $pwHash));
$this->assertFalse($hash->check($str.'f00', $pwHash));
}
public function testSha512Hash()
{
$psl = new \phpSec\Core();
$hash = $psl['crypt/hash'];
$hash->method = \phpSec\Crypt\Hash::SHA512;
$str = 'some string';
$pwHash = $hash->create($str);
$this->assertTrue($hash->check($str, $pwHash));
$this->assertFalse($hash->check($str.'f00', $pwHash));
}
}