-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
110 lines (94 loc) · 4.61 KB
/
index.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SecureCapsule</title>
<link rel="icon" href="secure.gif" type="gif">
<!-- Link to Tailwind CSS -->
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<style>
/* Custom CSS for the background image */
body {
background-image: url("abstract.jpg");
background-size: cover;
background-position: center center;
background-attachment: fixed;
}
/* Custom CSS for result data */
#resultData {
max-height: 200px;
overflow-y: auto;
}
</style>
</head>
<body class="bg-black text-white">
<div class="container mx-auto p-4 flex flex-col justify-center items-center min-h-screen">
<!-- Navigation Bar -->
<nav class="w-full p-4 mb-8 bg-black bg-opacity-80">
<div class="container mx-auto">
<div class="flex justify-center items-center">
<a href="#" class="text-white text-xl font-bold">Message Encryption and Decryption Algorithm</a>
<div class="hidden md:block">
<!-- Add additional navigation links here if needed -->
</div>
</div>
</div>
</nav>
<div class="w-full max-w-md">
<center>
<h2 class="text-3xl text-black font-bold mb-8">
Secure Capsule
<img src="secure.gif" alt="Secure GIF" class="inline-block w-8 h-8">
</h2>
</center>
<form id="myForm" class="bg-black bg-opacity-70 rounded p-6">
<label for="inputData" class="block font-medium text-lg text-white mb-2">Enter a message:</label>
<textarea id="inputData" class="w-full px-3 py-2 border rounded-md text-black focus:outline-none focus:border-indigo-500 bg-white" rows="4"></textarea>
<div class="flex justify-center space-x-4 mt-6">
<button type="button" id="encryptBtn" class="bg-white text-black font-medium rounded px-4 py-2 hover:bg-green-600 focus:outline-none focus:bg-indigo-600">
Encrypt
</button>
<button type="button" id="decryptBtn" class="bg-white text-black font-medium rounded px-4 py-2 hover:bg-red-500 focus:outline-none focus:bg-indigo-600">
Decrypt
</button>
</div>
</form>
<div id="resultDiv" class="mt-6 hidden">
<h2 class="text-xl font-bold mb-2">Result:</h2>
<p class="text-white text-xs mt-2">Note: Copy the encrypted key and paste it in the message box again and click decrypt</p>
<div id="resultData" class="bg-gray-800 p-4 rounded text-white"></div>
</div>
</div>
</div>
<!-- Link to CryptoJS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script>
const encryptBtn = document.getElementById('encryptBtn');
const decryptBtn = document.getElementById('decryptBtn');
const inputData = document.getElementById('inputData');
const resultDiv = document.getElementById('resultDiv');
const resultData = document.getElementById('resultData');
encryptBtn.addEventListener('click', () => {
// Get the data from the textarea
const data = inputData.value;
// Encrypt the data using CryptoJS (you can use any encryption algorithm supported by CryptoJS)
const encryptedData = CryptoJS.AES.encrypt(data, 'secret_key').toString();
// Display the encrypted data on the page
resultData.textContent = `Encrypted Data: ${encryptedData}`;
// Show the result div
resultDiv.classList.remove('hidden');
});
decryptBtn.addEventListener('click', () => {
// Get the encrypted data from the textarea
const encryptedData = inputData.value;
// Decrypt the data using CryptoJS
const decryptedData = CryptoJS.AES.decrypt(encryptedData, 'secret_key').toString(CryptoJS.enc.Utf8);
// Display the decrypted data on the page
resultData.textContent = `Decrypted Data: ${decryptedData}`;
// Show the result div
resultDiv.classList.remove('hidden');
});
</script>
</body>
</html>