blob: 998d806b353e7b366ac03f95612cd7e1cb3831b0 (
plain)
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 Encrypt_test extends CI_TestCase {
public function set_up()
{
$this->encrypt = new Mock_Libraries_Encrypt();
$this->ci_instance_var('encrypt', $this->encrypt);
$this->ci_set_config('encryption_key', "Encryptin'glike@boss!");
$this->msg = 'My secret message';
}
// --------------------------------------------------------------------
public function test_encode()
{
$this->assertNotEquals($this->msg, $this->encrypt->encode($this->msg));
}
// --------------------------------------------------------------------
public function test_decode()
{
$encoded_msg = $this->encrypt->encode($this->msg);
$this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg));
}
// --------------------------------------------------------------------
public function test_optional_key()
{
$key = 'Ohai!ù0129°03182%HD1892P0';
$encoded_msg = $this->encrypt->encode($this->msg, $key);
$this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg, $key));
}
// --------------------------------------------------------------------
public function test_default_cipher()
{
$this->assertEquals('rijndael-256', $this->encrypt->get_cipher());
}
// --------------------------------------------------------------------
public function test_set_cipher()
{
$this->encrypt->set_cipher(MCRYPT_BLOWFISH);
$this->assertEquals('blowfish', $this->encrypt->get_cipher());
}
// --------------------------------------------------------------------
public function test_default_mode()
{
$this->assertEquals('cbc', $this->encrypt->get_mode());
}
// --------------------------------------------------------------------
public function test_set_mode()
{
$this->encrypt->set_mode(MCRYPT_MODE_CFB);
$this->assertEquals('cfb', $this->encrypt->get_mode());
}
}
|