forked from wwwtyro/cryptico
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
142 lines (66 loc) · 3.79 KB
/
test.html
File metadata and controls
142 lines (66 loc) · 3.79 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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript" type="text/javascript" src="jsbn.js"></script>
<script language="JavaScript" type="text/javascript" src="random.js"></script>
<script language="JavaScript" type="text/javascript" src="hash.js"></script>
<script language="JavaScript" type="text/javascript" src="rsa.js"></script>
<script language="JavaScript" type="text/javascript" src="aes.js"></script>
<script language="JavaScript" type="text/javascript" src="api.js"></script>
<script>
function print(string)
{
document.write(string + "\n\n");
}
print("<h1>Unsigned:</h1>");
var PassPhrase = "The Moon is a Harsh Mistress.";
var Bits = 512;
print("Matt's passphrase: " + PassPhrase);
print("Bit length: " + Bits);
var MattsRSAkey = cryptico.generateRSAKey(PassPhrase, Bits);
var MattsPublicKeyString = cryptico.publicKeyString(MattsRSAkey);
print("Matt's public key string:");
print(MattsPublicKeyString);
var PlainText = "Matt, j'écris en UTF-8";
print("Sam's message: " + PlainText);
var EncryptionResult = cryptico.encrypt(PlainText, MattsPublicKeyString);
print("The encrypted message:");
print(EncryptionResult.cipher);
var DecryptionResult = cryptico.decrypt(EncryptionResult.cipher, MattsRSAkey);
print("The decrypted message:");
print(DecryptionResult.plaintext);
print("DecryptionResult.signature: " + DecryptionResult.signature);
print("<h1>Signed, good signature:</h1>");
var PassPhrase = "There Ain't No Such Thing As A Free Lunch.";
var Bits = 512;
var SamsRSAkey = cryptico.generateRSAKey(PassPhrase, Bits);
var PlainText = "Matt, I need you to help me with my Starcraft strategy.";
var EncryptionResult = cryptico.encrypt(PlainText, MattsPublicKeyString, SamsRSAkey);
print("Sam's public key ID: " + cryptico.publicKeyID(cryptico.publicKeyString(SamsRSAkey)));
print("The encrypted message:");
print(EncryptionResult.cipher);
var DecryptionResult = cryptico.decrypt(EncryptionResult.cipher, MattsRSAkey);
print("The decrypted message:");
print(DecryptionResult.plaintext);
print("DecryptionResult.signature: " + DecryptionResult.signature);
print("The signature public key string:");
print(DecryptionResult.publicKeyString);
print("The signature public key ID:");
print(cryptico.publicKeyID(DecryptionResult.publicKeyString));
print("<h1>Signed, forged signature:</h1>");
EncryptionResult.cipher = "MCLk/K7l2xJU7s/KfteovUJo+z+XNujMlKxpMUMAR3RE/G36VJ4seDu8GJRWmlNkjPIxs3oH431KK7lIkz3U0w==?XWaxT2vVYUKNeR5FDYfzNMYDwkBGqx27jiI4Bz3oBp+Elie5c0rJh0suYHBlPvfO"
print("The encrypted message:");
print(EncryptionResult.cipher);
var DecryptionResult = cryptico.decrypt(EncryptionResult.cipher, MattsRSAkey);
print("The decrypted message:");
print(DecryptionResult.plaintext);
print("DecryptionResult.signature: " + DecryptionResult.signature);
print("The signature public key string:");
print(DecryptionResult.publicKeyString);
print("The signature public key ID:");
print(cryptico.publicKeyID(DecryptionResult.publicKeyString));
</script>
</head>
<body style="font-family: monospace; white-space:pre;">
</body>
</html>