Example #1
0
        public string receiveMessage(string cipherText)
        {
            turnDiffieHellmanRatchet();
            turnReceivingRatchet();
            var plainText = CryptUtils.SimpleAESDecryption(outputChain.latest.value, cipherText, outputChain.latest.nonce);

            receiveDiffieHellmanParameters();
            sendDiffieHellmanParameters();
            return plainText
        }
Example #2
0
        public void sendMessage(string message)
        {
            turnDiffieHellmanRatchet();
            turnSendingRatchet();
            var cipherText = CryptUtils.SimpleAESEncryption(outputChain.latest.value, message, outputChain.latest.nonce);

            Post(server, HttpContentTypes.TextPlain, new { message = cipherText });
            sendDiffieHellmanParameters();
            receiveDiffieHellmanParameters();
        }
Example #3
0
        public Dictionary <string, string> findKey(string website)
        {
            var credentials = new Dictionary <string, string>();
            var document    = collection.Find(new BsonDocument {
                { "website", website }
            }).FirstOrDefault();
            var decryptedData        = CryptUtils.SimpleAESDecryption(secretKey, document["credentials"].ToString(), Encoding.UTF8.GetBytes(document["nonce"].ToString()));
            var decryptedCredentials = decryptedData.Split(new[] { separator }, StringSplitOptions.None);

            credentials["username"] = decryptedCredentials[0];
            credentials["password"] = decryptedCredentials[1];
            return(credentials);
        }