Location: PHPKode > scripts > OTP_TS > otp_ts/example_txt.php


 * 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); 

$time_start = getmicrotime();

/* code */

include ('class.OTP_TS.php');

$secretdata = "In cryptography, the one-time pad (OTP) is an encryption algorithm where the plaintext is combined with a random key or \"pad\" that is as long as the plaintext and used only once. A modular addition is used to combine the plaintext with the pad. (For binary data, the operation XOR amounts to the same thing.) It was invented in 1917. If the key is truly random, never reused, and kept secret, the one-time pad provides perfect secrecy. It has also been proven that any cipher with perfect secrecy must use keys with the same requirements as OTP keys. The key normally consists of a random stream of numbers, each of which indicates the number of places in the alphabet (or number stream, if the plaintext message is in numerical form) which the corresponding letter or number in the plaintext message should be shifted. For messages in the Latin alphabet, for example, the key will consist of a random string of numbers from 0 to 25; for binary messages the key will consist of a random string of 0s and 1s; and so on.";
$password = "Secret password";

$OTP_TS = &new OTP_TS();
$code = $OTP_TS -> cipher_OTP_TS($password, $secretdata);
echo $code;
echo "<br /><br /><hr />";
echo $OTP_TS -> cipher_OTP_TS($password, $code);

/* code end */

$time_end = getmicrotime();
$time = $time_end - $time_start;

echo "<br /><br /><hr />";
echo 'It execute in '.$time.' s.';

Return current item: OTP_TS