mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 20:21:16 +00:00
add two function to encrypt and decrypt a string
not used yet
This commit is contained in:
parent
40ad10b45f
commit
bb7eed2730
|
@ -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);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user