<?php
class Cipher {
private $securekey, $iv;
function __construct($textkey) {
$this->securekey = hash('sha256',$textkey,TRUE);
$this->iv = mcrypt_create_iv(32);
}
function encrypt($input) {
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->securekey, $input, MCRYPT_MODE_ECB, $this->iv));
}
function decrypt($input) {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->securekey, base64_decode($input), MCRYPT_MODE_ECB, $this->iv));
}
}
if($_GET['on']=="1"){
$cipher = new Cipher('miclavesegura');
$encryptedtext = $cipher->encrypt(urldecode($_GET['in']));
echo '<input type="text" value="'.urlencode($encryptedtext).'" size="200"><br/>';
}else if($_GET['v']!=""){
if(stristr($_SERVER['HTTP_REFERER'],"misitio.com")===FALSE){
header("location: http://www.w3schools.com/html/mov_bbb.mp4");
die();
}
$cipher = new Cipher('miclavesegura');
$decryptedtext = $cipher->decrypt($_GET['v']);
if($decryptedtext!="")
header('location: '.$decryptedtext);
else
header("location: http://www.w3schools.com/html/mov_bbb.mp4");
}
die();
?>