|
Posted by Greg Donald on 10/01/49 11:05
On Wed, 12 Jan 2005 10:13:08 -0000, Shaun <shaunthornburgh@hotmail.com> wrote:
> I have site that allows users to upload private information to our server.
> We would like to encrypt the data for security reasons and only allow
> certain users to be able to un-encrypt the data and view it. I have looked
> at the PHP encryption functions and they appear to be one way algorithms - I
> am guessing this is the whole point of encrption ;)
>
> Does anyone have any suggestions regarding this?
function encrypt( $string )
{
$key = '&g1@8477Fg9*';
$result = '';
for( $i = 1; $i <= strlen( $string ); $i++ )
{
$char = substr( $string, $i - 1, 1 );
$keychar = substr( $key, ( $i % strlen( $key ) ) - 1, 1 );
$char = chr( ord( $char ) + ord( $keychar ) );
$result .= $char;
}
return $result;
}
function decrypt( $string )
{
$key = '&g1@8477Fg9*';
$result = '';
for( $i = 1; $i <= strlen( $string ); $i++ )
{
$char = substr( $string, $i - 1, 1 );
$keychar = substr( $key, ( $i % strlen( $key ) ) - 1, 1 );
$char = chr( ord( $char ) - ord( $keychar ) );
$result .= $char;
}
return $result;
}
--
Greg Donald
Zend Certified Engineer
http://destiney.com/
Navigation:
[Reply to this message]
|