Kyberia v2.3 - 1st revision from SVN (Without patches of kyberia.sk team)
[mirrors/Kyberia-bloodline.git] / inc / crypto.inc
1 <?php
2
3 class crypto {
4
5 function crypto($text,$key) {
6 /* Open the cipher */
7 $td = mcrypt_module_open('rijndael-256', '', 'ecb', '');
8
9 /* Create the IV and determine the keysize length */
10 $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
11 $ks = mcrypt_enc_get_key_size($td);
12
13 /* Intialize encryption */
14 mcrypt_generic_init($td, $key, "iv");
15
16 /* Encrypt data */
17 echo "LALALAL $iv LLALALAAL";
18 $encrypted = mcrypt_generic($td, $text);
19
20 /* Terminate encryption handler */
21 mcrypt_generic_deinit($td);
22 mcrypt_module_close($td);
23
24 return $encrypted;
25 }
26
27
28 function decrypto($encrypted,$key) {
29 $td = mcrypt_module_open('rijndael-256', '', 'ecb', '');
30
31 /* Create the IV and determine the keysize length */
32 $ks = mcrypt_enc_get_key_size($td);
33
34 // $iv=substr($encrypted,0,mcrypt_get_iv_size($td));
35 // $text=substr($encrypted,mcrypt_get_iv_size($td));
36
37 mcrypt_generic_init($td, $key, "iv");
38
39 /* Decrypt encrypted string */
40 $decrypted = mdecrypt_generic($td, $encrypted);
41
42 /* Terminate decryption handle and close module */
43 mcrypt_generic_deinit($td);
44 mcrypt_module_close($td);
45
46
47 return $decrypted;
48 }
49
50
51 }
52
53 ?>
This page took 0.295521 seconds and 4 git commands to generate.