Add new directory structure. Tags will contain current and past releases, and stable will contain any bug fixes to the current stable release so users won't have to get the potentially broken trunk build to fix a screwup in stable.
Trunk updated to 0.9 git-svn-id: http://kusabax.cultnet.net/svn/repo/stable@176 73d99b7e-4f53-4972-b7b7-2ecd3c4d89ee
This commit is contained in:
commit
88bacfad9c
316 files changed
+79806
No files matched your search
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* Common encryption functions
|
||||
*
|
||||
* Allow for more advanced encryption using the random seed set in the
|
||||
* configuration.
|
||||
*/
|
||||
function get_rnd_iv($iv_len) {
|
||||
$iv = '';
|
||||
while ($iv_len-- > 0) {
|
||||
$iv .= chr(mt_rand() & 0xff);
|
||||
}
|
||||
return $iv;
|
||||
}
|
||||
function md5_encrypt($plain_text, $password, $iv_len = 16) {
|
||||
$plain_text .= "\x13";
|
||||
$n = strlen($plain_text);
|
||||
if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16));
|
||||
$i = 0;
|
||||
$enc_text = get_rnd_iv($iv_len);
|
||||
$iv = substr($password ^ $enc_text, 0, 512);
|
||||
while ($i < $n) {
|
||||
$block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv));
|
||||
$enc_text .= $block;
|
||||
$iv = substr($block . $iv, 0, 512) ^ $password;
|
||||
$i += 16;
|
||||
}
|
||||
return base64_encode($enc_text);
|
||||
}
|
||||
function md5_decrypt($enc_text, $password, $iv_len = 16) {
|
||||
$enc_text = base64_decode($enc_text);
|
||||
$n = strlen($enc_text);
|
||||
$i = $iv_len;
|
||||
$plain_text = '';
|
||||
$iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512);
|
||||
while ($i < $n) {
|
||||
$block = substr($enc_text, $i, 16);
|
||||
$plain_text .= $block ^ pack('H*', md5($iv));
|
||||
$iv = substr($block . $iv, 0, 512) ^ $password;
|
||||
$i += 16;
|
||||
}
|
||||
return preg_replace('/\\x13\\x00*$/', '', $plain_text);
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user