From bb7eed2730befd3605f7b26949b101ee1f793deb Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 3 Sep 2013 08:23:23 +0200 Subject: [PATCH] add two function to encrypt and decrypt a string not used yet --- inc/inc.Utils.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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); +} + ?>