Return to Snippet

Revision: 1313
at September 27, 2006 11:33 by gdonald


Updated Code
function encrypt( $string )
{
  $key = 'BXcfTYewQ';
  $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 = 'BXcfTYewQ';
  $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;
}

Revision: 1312
at September 27, 2006 11:33 by gdonald


Initial Code
function encrypt( $string )
{
  $key = 'BXcfTYewQ';
  $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 = 'BXcfTYewQ';
  $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;
}

Initial URL

                                

Initial Description

                                

Initial Title
PHP poor man's crypt

Initial Tags

                                

Initial Language
PHP