Untitled
unknown
plain_text
10 months ago
1.2 kB
12
Indexable
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cipher Tool</title>
</head>
<body>
<h1>Message Encryptor</h1>
<textarea id="inputText" placeholder="Enter your message here"></textarea><br>
<button onclick="encryptMessage()">Encrypt</button>
<h2>Encrypted Message</h2>
<p id="outputText"></p>
<script>
function encryptMessage() {
let input = document.getElementById("inputText").value;
let encrypted = '';
for (let char of input) {
if (char >= 'A' && char <= 'Z') {
encrypted += String.fromCharCode(((char.charCodeAt(0) - 65 + 3) % 26) + 65);
} else if (char >= 'a' && char <= 'z') {
encrypted += String.fromCharCode(((char.charCodeAt(0) - 97 + 3) % 26) + 97);
} else {
encrypted += char; // Non-letter characters remain unchanged
}
}
document.getElementById("outputText").innerText = encrypted;
}
</script>
</body>
</html>
Editor is loading...
Leave a Comment