On Wed, 12 Jan 2005 10:13:08 -0000, Shaun <[EMAIL PROTECTED]> 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 = '&[EMAIL PROTECTED]';
        
    $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 = '&[EMAIL PROTECTED]';
        
    $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

Reply via email to