diff options
author | Friendika <info@friendika.com> | 2011-08-20 04:53:11 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-08-20 04:53:11 -0700 |
commit | 0d9d576aa642e02eb8673aa20bdf4b6a18ae6bc3 (patch) | |
tree | cf41c9c4bc72a345f8a05896b82d54c06074dbf0 /include/text.php | |
parent | 6aa633efc829d4d3e9ccba4f6fb4d555f3c968ca (diff) | |
download | volse-hubzilla-0d9d576aa642e02eb8673aa20bdf4b6a18ae6bc3.tar.gz volse-hubzilla-0d9d576aa642e02eb8673aa20bdf4b6a18ae6bc3.tar.bz2 volse-hubzilla-0d9d576aa642e02eb8673aa20bdf4b6a18ae6bc3.zip |
move encryption functions to crypto file
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/include/text.php b/include/text.php index b13cf980f..66447069e 100644 --- a/include/text.php +++ b/include/text.php @@ -620,32 +620,6 @@ function valid_email($x){ }} -if(! function_exists('aes_decrypt')) { -function aes_decrypt($val,$ky) -{ - $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - for($a=0;$a<strlen($ky);$a++) - $key[$a%16]=chr(ord($key[$a%16]) ^ ord($ky[$a])); - $mode = MCRYPT_MODE_ECB; - $enc = MCRYPT_RIJNDAEL_128; - $dec = @mcrypt_decrypt($enc, $key, $val, $mode, @mcrypt_create_iv( @mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM ) ); - return rtrim($dec,(( ord(substr($dec,strlen($dec)-1,1))>=0 and ord(substr($dec, strlen($dec)-1,1))<=16)? chr(ord( substr($dec,strlen($dec)-1,1))):null)); -}} - - -if(! function_exists('aes_encrypt')) { -function aes_encrypt($val,$ky) -{ - $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - for($a=0;$a<strlen($ky);$a++) - $key[$a%16]=chr(ord($key[$a%16]) ^ ord($ky[$a])); - $mode=MCRYPT_MODE_ECB; - $enc=MCRYPT_RIJNDAEL_128; - $val=str_pad($val, (16*(floor(strlen($val) / 16)+(strlen($val) % 16==0?2:1))), chr(16-(strlen($val) % 16))); - return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv( mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); -}} - - /** * * Function: linkify @@ -903,20 +877,6 @@ function generate_user_guid() { } -function pkcs5_pad ($text, $blocksize) -{ - $pad = $blocksize - (strlen($text) % $blocksize); - return $text . str_repeat(chr($pad), $pad); -} - -function pkcs5_unpad($text) -{ - $pad = ord($text{strlen($text)-1}); - if ($pad > strlen($text)) return false; - if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false; - return substr($text, 0, -1 * $pad); -} - function base64url_encode($s, $strip_padding = false) { |