Login   Register  
PHP Classes
elePHPant
Icontem

File: TxtCrypt_CommandLine_Example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2005-03-26 17:23
Size: 839 bytes
 

Contents

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

  if (
$argc == && 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 == && 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";
    }
?>