This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 344
/
test.html
148 lines (73 loc) · 4.13 KB
/
test.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
111
112
113
114
115
<html>
<head>
<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, I need you to help me with my Starcraft strategy.";
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 = "FrD9P9pbSuCpaMExcHI/6WHbrOgLlIWWegHrWRLN027+DekkaVzumh8QbCS7\n\
6BZJpfQ0H0b/pEvPCnE9RNqFFQ==?h7W8J7KrqDd7TCDlOolSUPwRNxoJYoQ\n\
o7h62SDsfLTfKcdzi6DUTfEq7DgsIKIZd8nYYrDmn3F1utFlgVja2mXSD7FY\n\
RRNvYbmpmu3WBozG77hyFup3IlEQeOkKLBk9G1uEYGcrXiIktJiYBvn8ltVP\n\
Qdo6cViIkwYjEdNoCIanYsSO+YB20EyuKfDj0p62QW9sAVx8jeQmY+f7cvWj\n\
/3evPfZ2D3gaXXT+QY2mu+0ap8P89rPFmrlMgMVFRye4FEWHSkSiKtrddt1y\n\
DZoMxwxFytKA2QciN7MHgZRZ16kcO1KjpPlb9jSXDbzllCWDhigN+kvBog4L\n\
GvhTe0CEn5HKGpWx1+TGbC7pim6/KOFo34DScLOrclUNGl0VY8W+/+EBXhin\n\
dthvRRcjy+0BRn4tDpC4QJjdJoXCqDmT3NRU="
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>