diff options
author | marvin-borner@live.com | 2018-04-11 18:36:44 +0200 |
---|---|---|
committer | marvin-borner@live.com | 2018-04-11 18:36:44 +0200 |
commit | 2a221f180ebf6f86e3709401804108fcda65184f (patch) | |
tree | f947f37deb7d0192a3c6aed15ffd30d9c7aeea6b /TestEncryption.php | |
parent | a935f6bc393490d02119e9c6cbc62787b3656fac (diff) |
Started implementing chat encryption
Diffstat (limited to 'TestEncryption.php')
-rw-r--r-- | TestEncryption.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/TestEncryption.php b/TestEncryption.php index e4a9085..097b727 100644 --- a/TestEncryption.php +++ b/TestEncryption.php @@ -14,18 +14,26 @@ <script src="assets/js/encryption.js"></script>
<script>
// The passphrase used to repeatably generate this RSA key.
- var PassPhrase = "The Moon is a Harsh Mistress.";
-
+ var PassPhrase = randomString(16);
// The length of the RSA key, in bits.
var Bits = 1024;
-
var MattsRSAkey = cryptico.generateRSAKey(PassPhrase, Bits);
var MattsPublicKeyString = cryptico.publicKeyString(MattsRSAkey);
- var PlainText = "Matt, I need you to help me with my Starcraft strategy.";
+ var PlainText = "Hello Bro";
var EncryptionResult = cryptico.encrypt(PlainText, MattsPublicKeyString);
-
console.log(EncryptionResult.cipher);
+
+ function randomString(len, charSet) {
+ charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ var randomString = '';
+ for (var i = 0; i < len; i++) {
+ var randomPoz = Math.floor(Math.random() * charSet.length);
+ randomString += charSet.substring(randomPoz,randomPoz+1);
+ }
+ return randomString;
+ }
+
</script>
</body>
</html>
\ No newline at end of file |