<!DOCTYPE html>
<!--
/**
* SimpleEncrypt - PHP Class to encrypt and decrypt data
*
* Tested and working on PHP 4.3.2 and higher
*
* LICENSE: This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License v2 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* @author Alex Suarez <kapirucho@gmail.com>
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
* @version 0.1
*/
-->
<?php
include_once 'simpleencrypt.php';
if(isset($_POST['toEncrypt'])){
$toencrypt = filter_input(INPUT_POST, 'toEncrypt', FILTER_SANITIZE_SPECIAL_CHARS);
$super_secret_key = 'fhdjd65ahd92hdjd73658';//This should be something only you know about and no one else
//Start encrypt class
$enc = new SimpleEncrypt($super_secret_key);
/**
* Do encrypt
* value to be stored in DB or maybe in $_SESSION
*/
$encrypted = $enc->Encrypt($toencrypt);
/**
* Do decrypt
*/
$decrypted = $enc->Decrypt($encrypted);
}
?>
<html>
<head>
<title>Encrypt example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div>
<label>Encrypted: <strong><?php echo $encrypted; ?></strong></label><br>
<label>Decrypted: <strong><?php echo $decrypted; ?></strong></label><br>
<form action="" method="POST">
<input type="text" name="toEncrypt">
<input type="submit">
</form>
</div>
</body>
</html>
|