PHP Classes

File: TxtCrypt_CommandLine_Example.php

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

Contents

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

  if (
$argc == 6 && strcmp($argv[1], "-e") == 0) {
   
$txEnc = new TxtCrypt();
    if (
$txEnc->Encrypt($argv[2], $argv[3], $argv[4], $argv[5]) == false)
      echo
$txEnc->GetErrorMessage()."\n";
    else
      echo
"File ".$argv[3]." was encrypted and save as ".$argv[4]."\n";
    }
  else if (
$argc == 5 && strcmp($argv[1], "-d") == 0) {
   
$txEnc = new TxtCrypt();
    if (
$txEnc->Decrypt($argv[2], $argv[3], $argv[4]) == false)
      echo
$txEnc->GetErrorMessage()."\n";
    else
      echo
"File ".$argv[2]." was decrypted and save as ".$argv[3]."\n";
    }
  else {
    echo
"Usage:\n";
    echo
" php -f TxtCrypt_CommandLine_Example.php -e CarrierFile InFile OutFile Key\n";
    echo
" php -f TxtCrypt_CommandLine_Example.php -d InFile OutFile Key\n";
    }
?>