Made things functional, decrypt still doesn't work
This commit is contained in:
17
decrypt.php
Normal file
17
decrypt.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<title>Decrypt file</title>
|
||||
<meta name=viewport content=width=device-width,initial-scale=1.0>
|
||||
<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>
|
||||
</body>
|
||||
</html>
|
||||
30
decryptFunc.php
Normal file
30
decryptFunc.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require "enc.php";
|
||||
$data = $_POST["words"];
|
||||
|
||||
//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>";
|
||||
|
||||
//Get the tag
|
||||
preg_match('#(?<=(<tag>))(.*?)(<\/tag>)#', $data, $tagArr);
|
||||
$tag = bin2hex($tagArr[0]);
|
||||
$tag = substr($tag, 0, strlen("</tag>"));
|
||||
echo "tag is $tag <br>";
|
||||
|
||||
//Get the ciphertext
|
||||
preg_match('#(?<=(<content>))(.*?)(<\/content>)#', $data, $ctArr);
|
||||
$ciphertext = $ctArr[0];
|
||||
$ciphertext = substr($ciphertext, 0, strlen("</content>"));
|
||||
echo "text is $ciphertext <br>";
|
||||
|
||||
$content = decrypt($ciphertext, $key, $iv, $tag);
|
||||
echo "content is:<br>"; var_dump($content);
|
||||
?>
|
||||
59
error_log
Normal file
59
error_log
Normal file
@@ -0,0 +1,59 @@
|
||||
[08-Apr-2019 22:38:51 America/New_York] PHP Notice: Undefined variable: current_key in /home/lukeuxao/public_html/cs/submit.php on line 3
|
||||
[08-Apr-2019 22:38:51 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
|
||||
[08-Apr-2019 22:41:11 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
|
||||
[08-Apr-2019 22:41:25 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:41:25 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:42:00 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:42:00 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:42:28 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:42:28 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:42:53 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:42:53 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:43:33 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:43:33 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:43:33 America/New_York] PHP Notice: Undefined index: file in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:44:04 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:44:04 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:44:04 America/New_York] PHP Notice: Undefined index: encrypted.txt in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:44:13 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:44:13 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:44:13 America/New_York] PHP Notice: Undefined index: encrypted in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:45:21 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:45:21 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:45:21 America/New_York] PHP Notice: Undefined index: upload_file in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
|
||||
[08-Apr-2019 22:45:21 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
|
||||
[08-Apr-2019 22:47:24 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:47:24 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:47:24 America/New_York] PHP Notice: Undefined index: upload_file in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
|
||||
[08-Apr-2019 22:47:24 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 5
|
||||
[08-Apr-2019 22:47:43 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:47:43 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:48:15 America/New_York] PHP Notice: Undefined index: uploadFile in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:48:15 America/New_York] PHP Warning: fopen(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 22:48:15 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:48:15 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:51:00 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:51:00 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:51:03 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:51:03 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:51:07 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:51:07 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:53:04 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:53:04 America/New_York] PHP Warning: file_get_contents(): Filename cannot be empty in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 22:55:21 America/New_York] PHP Notice: Undefined index: doc in /home/lukeuxao/public_html/cs/decryptFunc.php on line 4
|
||||
[08-Apr-2019 23:01:42 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
|
||||
[08-Apr-2019 23:01:50 America/New_York] PHP Notice: Undefined offset: 3 in /home/lukeuxao/public_html/cs/submit.php on line 4
|
||||
[08-Apr-2019 23:04:28 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
|
||||
[08-Apr-2019 23:04:33 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
|
||||
[08-Apr-2019 23:04:42 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
|
||||
[08-Apr-2019 23:05:07 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
|
||||
[08-Apr-2019 23:05:23 America/New_York] PHP Warning: openssl_decrypt(): Setting tag for AEAD cipher decryption failed in /home/lukeuxao/public_html/cs/enc.php on line 14
|
||||
[08-Apr-2019 23:13:43 America/New_York] PHP Notice: Undefined variable: iv in /home/lukeuxao/public_html/cs/decryptFunc.php on line 13
|
||||
[08-Apr-2019 23:13:43 America/New_York] PHP Notice: Undefined variable: iv in /home/lukeuxao/public_html/cs/decryptFunc.php on line 25
|
||||
[08-Apr-2019 23:13:43 America/New_York] PHP Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in /home/lukeuxao/public_html/cs/enc.php on line 14
|
||||
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined index: words in /home/lukeuxao/public_html/cs/decryptFunc.php on line 3
|
||||
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined index: key in /home/lukeuxao/public_html/cs/decryptFunc.php on line 6
|
||||
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined offset: 0 in /home/lukeuxao/public_html/cs/decryptFunc.php on line 11
|
||||
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined offset: 0 in /home/lukeuxao/public_html/cs/decryptFunc.php on line 16
|
||||
[08-Apr-2019 23:14:25 America/New_York] PHP Notice: Undefined offset: 0 in /home/lukeuxao/public_html/cs/decryptFunc.php on line 21
|
||||
[08-Apr-2019 23:14:25 America/New_York] PHP Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in /home/lukeuxao/public_html/cs/enc.php on line 14
|
||||
25
index.php
25
index.php
@@ -3,34 +3,23 @@
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<title>Encrytion and stuff</title>
|
||||
<meta name="viewport" content=width=device-width,initial-scale=1.0>
|
||||
<link rel=stylesheet href=write.css type=text/css>
|
||||
<meta name=viewport content=width=device-width,initial-scale=1.0>
|
||||
<link rel=stylesheet href=style.css type=text/css>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
function wordCount(thing) {
|
||||
regex = /(\S\s)|(([A-Z]|[a-z])(\.|\!|\?|\z))/;
|
||||
numOfParenthesis = 5; //how many par. sets are in the regex
|
||||
wordsLeft = 500-((thing.value.split(regex).length-1)/numOfParenthesis);
|
||||
//if(wordsLeft<0){
|
||||
// wordsLeft = 0;
|
||||
//}
|
||||
//Include if the counter shouldn't go below 0
|
||||
document.getElementById("counter").innerHTML = wordsLeft;
|
||||
if(wordsLeft<=0){
|
||||
document.getElementById("submitWriting").disabled = false;
|
||||
}else{
|
||||
document.getElementById("submitWriting").disabled = true;
|
||||
}
|
||||
words = (thing.value.split(regex).length-1)/numOfParenthesis;
|
||||
document.getElementById("counter").innerHTML = words;
|
||||
}
|
||||
</script>
|
||||
<form action=submit.php method=POST>
|
||||
<h2 id=counter>500</h2>
|
||||
<h2 id=counter></h2>
|
||||
<textarea onkeyup=wordCount(this) placeholder='Write your words here...' name=words></textarea>
|
||||
<div id=writeButtons>
|
||||
<button type=submit name=submit value=save id=saveWriting>SAVE</button>
|
||||
<button type=submit name=submit value=submit id=submitWriting disabled>SUBMIT</button>
|
||||
</div>
|
||||
<input type=text name=key placeholder='Decryption key'>
|
||||
<button type=submit name=submit value=submit id=submitWriting>SUBMIT</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
18
submit.php
18
submit.php
@@ -1,15 +1,9 @@
|
||||
<?php
|
||||
require $root."enc.php";
|
||||
$enc = encrypt($_POST["words"], $current_key);
|
||||
$postID = bin2hex(openssl_random_pseudo_bytes(7));
|
||||
require "enc.php";
|
||||
$enc = encrypt($_POST["words"], $_POST["key"]);
|
||||
$content = '<iv>'.$enc[1].'</iv>'.'<tag>'.$enc[2].'</tag>'.'<content>'.$enc[0]."</content>";
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO posts (id, user_id, text, iv, tag) VALUES (:id, :uid, :txt, :iv, :tag)");
|
||||
$stmt->bindParam(":id", $postID);
|
||||
$stmt->bindParam(":uid", $current_userID);
|
||||
$stmt->bindParam(":txt", $enc[0]);
|
||||
$stmt->bindParam(":iv", $enc[1]);
|
||||
$stmt->bindParam(":tag", $enc[2]);
|
||||
$stmt->execute();
|
||||
|
||||
header("Location: /500/read/?post=".$postID);
|
||||
header('Content-type: text/plain');
|
||||
header('Content-Disposition: attachment; filename="encrypted.txt"');
|
||||
echo $content;
|
||||
?>
|
||||
Reference in New Issue
Block a user