-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOpenCryptTest.php
41 lines (31 loc) · 1.08 KB
/
OpenCryptTest.php
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
<?php
namespace OpenCrypt\Tests;
use OpenCrypt\OpenCrypt;
final class OpenCryptTest extends \PHPUnit\Framework\TestCase
{
public function testCrypt()
{
$secretKey = 'ec3a85570a2b2122ad835984ba12e91f';
$iv = base64_decode('hEHLyH4Irwqvnl8uJpHrnQ==');
$password = "OpenCrypt";
$openCrypt = new OpenCrypt($secretKey, $iv);
$this->assertEquals($iv, $openCrypt->iv());
$encryptedPassword = $openCrypt->encrypt($password);
$this->assertEquals('QDWPv3lyx9LaKuxIgIXooA==', $encryptedPassword);
$decryptedPassword = $openCrypt->decrypt($encryptedPassword);
$this->assertEquals($password, $decryptedPassword);
}
public function testGeneratingIV()
{
$secretKey = 'ec3a85570a2b2122ad835984ba12e91f';
$password = "OpenCrypt";
$openCrypt = new OpenCrypt($secretKey);
$iv = $openCrypt->iv();
$this->assertEquals(16, strlen($iv));
}
public function testGenerateKey()
{
$key = OpenCrypt::generateKey();
$this->assertEquals(1024, strlen($key));
}
}