PHP Classes

File: TxtCrypt_Webpage_Example.php

Recommend this page to a friend!
  Classes of Chao-Chyuan Shih   TxtCrypt   TxtCrypt_Webpage_Example.php   Download  
File: TxtCrypt_Webpage_Example.php
Role: Example script
Content type: text/plain
Description: Webpage Example
Class: TxtCrypt
Encrypt a file and hide it in a regular text file
Author: By
Last change:
Date: 19 years ago
Size: 1,150 bytes
 

Contents

Class file image Download
<?
 
include_once("./TxtCrypt_Class.php");

 
$type = 0; // default to encryption
 
$carrierFile = "";
 
$inFile = "";
 
$outFile = "";
 
$key = "";

  if (isset(
$_REQUEST['decrypt'])) $type = 1; // for decryption
 
if (isset($_REQUEST['carrier'])) $carrierFile = $_REQUEST['carrier'];
  if (isset(
$_REQUEST['infile'])) $inFile = $_REQUEST['infile'];
  if (isset(
$_REQUEST['outfile'])) $outFile = $_REQUEST['outfile'];
  if (isset(
$_REQUEST['key'])) $key = $_REQUEST['key'];

  if (
$type == 0 && $carrierFile != "" && $inFile != "" && $outFile != "" && $key != "") {
   
$txEnc = new TxtCrypt();
    if (
$txEnc->Encrypt($carrierFile, $inFile, $outFile, $key) == false)
      echo
$txEnc->GetErrorMessage()."<br />";
    else
      echo
"File ".$inFile." was encrypted and save as ".$outFile."<br />";
    }
  else if (
$type == 1 && $inFile != "" && $outFile != "" && $key != "") {
   
$txEnc = new TxtCrypt();
    if (
$txEnc->Decrypt($inFile, $outFile, $key) == false)
      echo
$txEnc->GetErrorMessage()."<br />";
    else
      echo
"File ".$inFile." was decrypted and save as ".$outFile."<br />";
    }
?>