Brought decryptFunc up to date with the rest of the site

This commit is contained in:
OakBaron (queso)
2019-04-21 13:57:07 -04:00
parent 3755484cba
commit e3743176e7
2 changed files with 37 additions and 14 deletions

View File

@@ -1,14 +1,34 @@
<?php <!DOCTYPE html>
require "enc.php"; <html>
$words = file_get_contents($_FILES["encDoc"]["tmp_name"]); <head>
$data = simplexml_load_string($words) or die("Couldn't make object"); <meta charset=utf-8>
<title>Encrytion and stuff</title>
//Get the XML info in variables (hex2bin the iv and tag) <meta name=viewport content=width=device-width,initial-scale=1.0>
$key = $_POST["key"]; <link rel=stylesheet href=style.css type=text/css>
$iv = hex2bin($data->iv); </head>
$tag = hex2bin($data->tag); <body class=center>
$ciphertext = $data->content; <?php
require "enc.php";
echo "Your decrypted content:<br>"; $words = file_get_contents($_FILES["encDoc"]["tmp_name"]);
echo decrypt($ciphertext, $key, $iv, $tag);; $data = simplexml_load_string($words) or die("Couldn't make object");
?>
//Get the XML info in variables (hex2bin the iv and tag)
$key = $_POST["key"];
$iv = hex2bin($data->iv);
$tag = hex2bin($data->tag);
$ciphertext = $data->content;
$dec = decrypt($ciphertext, $key, $iv, $tag);
if($dec != ""){
echo "<h2>Your decrypted content:</h2>";
echo "<p id=decCont>".$dec."</p>";
}else{
echo "<h2>Error</h2>";
echo "<p id=decCont>Your content could not be decrypted.<br>Wrong password, maybe?</p>";
}
?>
<br><br>
<p class=center><a href=/cs/encrypt.php>Encrypt another file</a></p>
<p class=center><a href=/cs/decrypt.php>Decrypt another file</a></p>
</body>
</html>

View File

@@ -40,6 +40,9 @@ textarea{
font-size: 0.9em; font-size: 0.9em;
color: inherit; color: inherit;
} }
#decCont{
font-family: monospace;
}
button{ button{
display: block; display: block;
margin-left: auto; margin-left: auto;