Fixed file uploading, other more minor fixes

This commit is contained in:
Luke Ogburn
2019-04-09 07:25:07 -04:00
parent 952948552f
commit 2fa158402e
6 changed files with 14 additions and 8 deletions

View File

@@ -7,11 +7,10 @@
<link rel=stylesheet href=style.css type=text/css>
</head>
<body>
<form action=decryptFunc.php method=POST enctype=multipart/form-data>
<!--<input type=file name=doc accept=.txt >-->
<textarea placeholder="Paste your encrypted file's contents here" name=words></textarea>
<input type=text name=key placeholder='Decryption key'>
<button type=submit name=submit value=submit id=submitWriting>SUBMIT</button>
<form method=POST action=decryptFunc.php enctype="multipart/form-data">
<input type=file name=encDoc>
<input type=text name=key placeholder='Decryption key'>
<button type=submit name=submit value=submit id=submitWriting>SUBMIT</button>
</form>
</body>
</html>

View File

@@ -1,6 +1,6 @@
<?php
require "enc.php";
$words = "<encrypted>".$_POST["words"]."</encrypted>";
$words = file_get_contents($_FILES["encDoc"]["tmp_name"]);
$data = simplexml_load_string($words) or die("Couldn't make object");
//Get the key

4
fileUpload.php Normal file
View File

@@ -0,0 +1,4 @@
<form method=POST action=uploaded.php enctype="multipart/form-data">
<input type=file name=encDoc>
<button type=submit>SUBMIT</button>
</form>

View File

@@ -16,7 +16,7 @@
}
</script>
<form action=submit.php method=POST>
<h2 id=counter></h2>
<h2 id=counter>0</h2>
<textarea onkeyup=wordCount(this) placeholder='Write your words here...' name=words></textarea>
<input type=text name=key placeholder='Decryption key'>
<button type=submit name=submit value=submit id=submitWriting>SUBMIT</button>

View File

@@ -1,7 +1,7 @@
<?php
require "enc.php";
$enc = encrypt($_POST["words"], $_POST["key"]);
$content = '<iv>'.bin2hex($enc[1]).'</iv>'.'<tag>'.bin2hex($enc[2]).'</tag>'.'<content>'.$enc[0]."</content>";
$content = "<encrypted>\n"." <iv>".bin2hex($enc[1])."</iv>\n"." <tag>".bin2hex($enc[2])."</tag>\n"." <content>".$enc[0]."</content>\n"."</encrypted>";
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="encrypted.txt"');

3
uploaded.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
echo file_get_contents($_FILES["encDoc"]["tmp_name"]);
?>