Re: Data Enryption

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 12 Jan 2005 10:13:08 -0000, Shaun <shaunthornburgh@xxxxxxxxxxx> 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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux