-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencnot.php
executable file
·78 lines (65 loc) · 2.85 KB
/
encnot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
session_start();
// Check if the user is logged in, otherwise redirect to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: ../login.php"); exit; }
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Encrypt Da notes</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js" integrity="sha256-xoJklEMhY9dP0n54rQEaE9VeRnBEHNSfyfHlKkr9KNk=" crossorigin="anonymous"></script>
<style type="text/css">
body{ font: 14px sans-serif; text-align: center; }
</style>
</head>
<body>
<?php
include '../navigator2.php';
?>
<div class="container">
<h2>Add Note</h2>
<p>:</p>
<form>
<div class="form-group">
<textarea class="form-control" type="text" rows="20" id="Message" name="fname"></textarea>
</div>
<button type="button" class="btn btn-primary" onclick="encrypt()">Save Note</button>
</form>
</div>
<script type="text/javascript">
if (localStorage.getItem('Password') == null) {window.location = "actions/setpassword.php";} //If password is nt set redirect to setpassword
function encrypt(){
var message = document.getElementById("Message").value;
if(message === "") {
swal.fire({
position: "top-end",
type: "error",
title: "Please write a note",
showConfirmButton: false,
timer: 1200
});
die();
}
var password = localStorage.getItem("Password");
var encrypted = CryptoJS.AES.encrypt(message, password, "{mode: CryptoJS.mode.CBC, padding:CryptoJs.pad.Pkcs7}").toString();
sendtodb(encrypted);
}
function sendtodb(note){
$.ajax({
url: "notesubmit.php",
type: "POST",
data: {note: note},
success: function(data){
window.location.replace("../view.php");
}
});
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
</body>
</html>