<?php
/*========================*\
* OTP_TS
* Written by: AS
* Mialto: hide@address.com
* Date: 2007-06-19
* Algorithm: one-time-pad ts (encryption and decryption)
* Version: 1
* Licencia: Lesser General Public License (LGPL)
*
* Copyright (C) 2007 Jacek Wloka
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
\*========================*/
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
include ('class.OTP_TS.php');
function read_file ($file) {
if ($f = @fopen($file, "rb")) {
$kod = @fread($f, @filesize($file));
@fclose($f);
}
return $kod;
}
function save_file ($code, $file, $key=0) {
if ($f = @fopen ($file, "wb")) {
@fwrite($f, OTP_TS::cipher_OTP_TS($key, $code));
@fclose($f);
return 1;
} else {
return 0;
}
}
$time_start = getmicrotime();
$password = "Secret password";
/* encryption file linux.bmp */
save_file(read_file('linux.bmp'), 'linux_ccc.bmp', $password);
/* and decryption file linux_ccc.bmp */
save_file(read_file('linux_ccc.bmp'), 'linux_2.bmp', $password);
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo 'It execute in '.$time.' s.';
?>