-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
143 lines (126 loc) Β· 4.15 KB
/
index.html
File metadata and controls
143 lines (126 loc) Β· 4.15 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>π Secure Text Encryptor & Decryptor</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
color: #fff;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
.container {
background-color: #1a1a1a;
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0,0,0,0.6);
max-width: 600px;
width: 100%;
text-align: center;
}
h1 {
background: linear-gradient(90deg, #00bfff, #4b6cb7);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-size: 2em;
margin-bottom: 20px;
}
input, textarea {
width: 100%;
padding: 12px;
margin: 10px 0;
background-color: #2e2e2e;
color: #fff;
border: none;
border-radius: 8px;
}
button {
padding: 12px 20px;
margin: 10px 5px;
border: none;
border-radius: 8px;
background: linear-gradient(90deg, #00bfff, #4b6cb7);
color: white;
font-weight: bold;
cursor: pointer;
transition: background 0.3s ease;
}
button:hover {
background: linear-gradient(90deg, #4b6cb7, #00bfff);
}
pre {
background-color: #2e2e2e;
padding: 15px;
border-radius: 8px;
overflow-x: auto;
}
</style>
</head>
<body>
<div class="container">
<h1>π Secure Text Encryptor & Decryptor</h1>
<input type="text" id="key" placeholder="Enter your secret key">
<textarea id="inputText" rows="4" placeholder="Type your message here..."></textarea>
<div>
<button onclick="encryptText()">Encrypt π</button>
<button onclick="decryptText()">Decrypt π</button>
</div>
<h3>π Output:</h3>
<pre id="output"></pre>
</div>
<script>
function encrypt(text, key) {
let result = '';
let keyLength = key.length;
for (let i = 0; i < text.length; i++) {
let char = text[i];
if (/[a-zA-Z]/.test(char)) {
let shift = key[i % keyLength].toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0);
if (char >= 'A' && char <= 'Z') {
result += String.fromCharCode((char.charCodeAt(0) - 'A'.charCodeAt(0) + shift) % 26 + 'A'.charCodeAt(0));
} else {
result += String.fromCharCode((char.charCodeAt(0) - 'a'.charCodeAt(0) + shift) % 26 + 'a'.charCodeAt(0));
}
} else {
result += char;
}
}
return result;
}
function decrypt(text, key) {
let result = '';
let keyLength = key.length;
for (let i = 0; i < text.length; i++) {
let char = text[i];
if (/[a-zA-Z]/.test(char)) {
let shift = key[i % keyLength].toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0);
if (char >= 'A' && char <= 'Z') {
result += String.fromCharCode((char.charCodeAt(0) - 'A'.charCodeAt(0) - shift + 26) % 26 + 'A'.charCodeAt(0));
} else {
result += String.fromCharCode((char.charCodeAt(0) - 'a'.charCodeAt(0) - shift + 26) % 26 + 'a'.charCodeAt(0));
}
} else {
result += char;
}
}
return result;
}
function encryptText() {
const key = document.getElementById("key").value;
const text = document.getElementById("inputText").value;
document.getElementById("output").innerText = encrypt(text, key);
}
function decryptText() {
const key = document.getElementById("key").value;
const text = document.getElementById("inputText").value;
document.getElementById("output").innerText = decrypt(text, key);
}
</script>
</body>
</html>