mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-03-16 22:10:31 +00:00
Updates on testing, message transport and objects
This commit is contained in:
parent
4b6de256aa
commit
8cd785280e
5 changed files with 3714 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,6 +1,4 @@
|
|||
*~
|
||||
*.log
|
||||
*credentials.json
|
||||
*node_modules
|
||||
.project
|
||||
.settings
|
||||
2
node_modules/.gitignore
generated
vendored
Normal file
2
node_modules/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!my-cryptico
|
||||
8
node_modules/my-cryptico/index.js
generated
vendored
Normal file
8
node_modules/my-cryptico/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
var fs = require('fs');
|
||||
// We do this so we use the exact same librar in the browser and in node
|
||||
// Read and eval library
|
||||
// Eval is evil...
|
||||
var filedata = fs.readFileSync('./webpages/public/js/cryptico.js','utf8');
|
||||
eval(filedata);
|
||||
|
||||
exports.cryptico = cryptico
|
||||
119
webpages/public/cryptotest.html
Normal file
119
webpages/public/cryptotest.html
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<script language="JavaScript" type="text/javascript" src="js/cryptico.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);
|
||||
print("The private key:");
|
||||
print(SamsRSAkey);
|
||||
console.log(SamsRSAkey);
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3585
webpages/public/js/cryptico.js
Normal file
3585
webpages/public/js/cryptico.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue