-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
43 lines (35 loc) · 1.57 KB
/
example.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
42
43
<?php
require_once 'Mcrypt.php';
$string = 'test';
$key = '1234567812345678';
echo "Module list: \n";
print_r(Mcrypt::getModuleList());
echo "\n";
echo "Mode list: \n";
print_r(Mcrypt::getModeList());
echo "\n";
// AES/ECB/PKCS5Padding
Mcrypt::setMode(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB, Mcrypt::PKCS5);
$encryptedString = Mcrypt::encrypt($string, $key);
$decryptedString = Mcrypt::decrypt($encryptedString, $key);
echo $string, " ", $encryptedString, " ", $decryptedString, "\n";
// AES/ECB/PKCS7Padding
Mcrypt::setMode(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB, Mcrypt::PKCS7);
$encryptedString = Mcrypt::encrypt($string, $key);
$decryptedString = Mcrypt::decrypt($encryptedString, $key);
echo $string, " ", $encryptedString, " ", $decryptedString, "\n";
// AES/ECB/ZEROPadding
Mcrypt::setMode(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB, Mcrypt::ZERO);
$encryptedString = Mcrypt::encrypt($string, $key);
$decryptedString = Mcrypt::decrypt($encryptedString, $key);
echo $string, " ", $encryptedString, " ", $decryptedString, "\n";
// AES/ECB/ISO10126Padding
Mcrypt::setMode(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB, Mcrypt::ISO10126);
$encryptedString = Mcrypt::encrypt($string, $key);
$decryptedString = Mcrypt::decrypt($encryptedString, $key);
echo $string, " ", $encryptedString, " ", $decryptedString, "\n";
// AES/ECB/ANSIX923Padding
Mcrypt::setMode(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB, Mcrypt::ANSIX923);
$encryptedString = Mcrypt::encrypt($string, $key);
$decryptedString = Mcrypt::decrypt($encryptedString, $key);
echo $string, " ", $encryptedString, " ", $decryptedString, "\n";