blob: 09ab51c335e063067cdc1da8ab3dc6f857613170 (
plain)
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
|
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<title>PassMan</title>
<link href="css/main.css" rel="stylesheet" id="stylelink">
<script src="scripts/aes.js"></script>
</head>
<body>
Source: <input type="text" id="source" value="Hello World"><br>
Passphrase: <input type="text" id="passphrase" value="Test"><br>
Result: <input type="text" id="result"><br>
Decrypted: <input type="text" id="decrypted"><br>
<input type="button" value="Encrypt" onclick="OnEncrypt()">
<input type="button" value="Decrypt" onclick="OnDecrypt()">
<input type="button" value="Clear" onclick="OnClear()">
<script>
function OnEncrypt()
{
var source = document.getElementById("source").value;
var phrase = document.getElementById("passphrase").value;
var encryptedAES = CryptoJS.AES.encrypt(source, phrase);
var str = encryptedAES.toString();
document.getElementById("result").value = str;
}
function OnDecrypt()
{
var source = document.getElementById("result").value;
var phrase = document.getElementById("passphrase").value;
var decryptedBytes = CryptoJS.AES.decrypt(source, phrase);
document.getElementById("decrypted").value = decryptedBytes.toString(CryptoJS.enc.Latin1);
}
function OnClear()
{
document.getElementById("decrypted").value = "";
}
</script>
</body>
</html>
<!-- vim: sw=4 ts=4
-->
|