diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index fb7b337e9..deb9c4d16 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -443,4 +443,21 @@ function checkQuota() { /* {{{ */ return ($quota - $user->getUsedDiskSpace()); } /* }}} */ + +function encryptData($key, $value){ + $text = $value; + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); + return $crypttext; +} + +function decryptData($key, $value){ + $crypttext = $value; + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypttext, MCRYPT_MODE_ECB, $iv); + return trim($decrypttext); +} + ?>