Location: PHPKode > projects > Skat Statistics > skatstat-1.7.1/skatstat/inc/encryption.php
<?php

/**
 * Function encrypts plain text with an simple algorithm
 *
 * @param string $plain_text
 * @return string (cypher text)
 */
function encrypt($plain_text) 
{
  $key = "ldjfsldjflsdkjfsldkfjecret";
  if( function_exists( "mcrypt_module_open" ) )
  {
    $plain_text = trim($plain_text);
    $iv = substr(md5($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
    $c_t = mcrypt_cfb (MCRYPT_CAST_256, $key, $plain_text, MCRYPT_ENCRYPT, $iv);
    return base64_encode($c_t);
  }
  else
  {
    return $plain_text;
  }
}


/**
 * Function decrypts the cyphertext
 */
function decrypt($c_t) 
{
  $key = "ldjfsldjflsdkjfsldkfjecret";
  if( function_exists( "mcrypt_module_open" ) )
  {
    $c_t = base64_decode($c_t);
    $iv = substr(md5($key), 0,
        mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
    $p_t = mcrypt_cfb (MCRYPT_CAST_256, $key, $c_t, MCRYPT_DECRYPT, $iv);
    return trim($p_t);
  }
  else
  {
    return $c_t;
  }
}

?>
Return current item: Skat Statistics