fixed decrypting
This commit is contained in:
@@ -1,30 +1,21 @@
|
||||
<?php
|
||||
require "enc.php";
|
||||
$data = $_POST["words"];
|
||||
$words = "<encrypted>".$_POST["words"]."</encrypted>";
|
||||
$data = simplexml_load_string($words) or die("Couldn't make object");
|
||||
|
||||
//Get the key
|
||||
$key = $_POST["key"];
|
||||
echo "key is $key <br>";
|
||||
|
||||
|
||||
//Get the IV
|
||||
preg_match('#(?<=(<iv>))(.*?)(<\/iv>)#', $data, $ivArr);
|
||||
$iv = $ivArr[0];
|
||||
$iv = substr($iv, 0, strlen("</content>"));
|
||||
echo "iv is $iv <br>";
|
||||
$iv = hex2bin($data->iv);
|
||||
|
||||
//Get the tag
|
||||
preg_match('#(?<=(<tag>))(.*?)(<\/tag>)#', $data, $tagArr);
|
||||
$tag = bin2hex($tagArr[0]);
|
||||
$tag = substr($tag, 0, strlen("</tag>"));
|
||||
echo "tag is $tag <br>";
|
||||
$tag = hex2bin($data->tag);
|
||||
|
||||
//Get the ciphertext
|
||||
preg_match('#(?<=(<content>))(.*?)(<\/content>)#', $data, $ctArr);
|
||||
$ciphertext = $ctArr[0];
|
||||
$ciphertext = substr($ciphertext, 0, strlen("</content>"));
|
||||
echo "text is $ciphertext <br>";
|
||||
$ciphertext = $data->content;
|
||||
|
||||
$content = decrypt($ciphertext, $key, $iv, $tag);
|
||||
echo "content is:<br>"; var_dump($content);
|
||||
echo "<pre>Your decrypted content:<br>";
|
||||
echo decrypt($ciphertext, $key, $iv, $tag);;
|
||||
?>
|
||||
Reference in New Issue
Block a user