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
<?php
protected function decryptInfo($toDecrypt) {
    	/* Open the cipher */
    	$td = mcrypt_module_open('rijndael-128', '', 'ecb', '');
    	
    	/* Create the IV and determine the keysize length, use MCRYPT_RAND
		 * on Windows instead */
		$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
		$ks = mcrypt_enc_get_key_size($td);
		
		/* Create key */
		$key = substr(md5('very secret key'), 0, $ks);
    	        
    	/* Intialize encryption */
	    mcrypt_generic_init($td, $key, $iv);
	    
	    
	    /* Decrypt encrypted string */
	    if(!$toDecrypt){
	    	return "";
	    }
		$decrypted = mdecrypt_generic($td, base64_decode($toDecrypt));
		
		/* Terminate decryption handle and close module */
		mcrypt_generic_deinit($td);
		mcrypt_module_close($td);
		
		return $decrypted;
    
    }