Beispiel #1
0
        public void EncryptAESCTR()
        {
            AESCipherCTR cipher   = new AESCipherCTR(key, 0);
            Base64       expected = new Base64("L77na/nrFsKvynd6HzOoG7GHTLXsTVu9qvY/2syLXzhPweyyMTJULu/6/kXX0KSvoOLSFQ==");
            string       data     = "Yo, VIP Let's kick it Ice, Ice, baby Ice, Ice, baby ";

            string encrypted = cipher.Encrypt(data);

            Assert.AreEqual(expected.Decode(), encrypted);
        }
        public Bytes[] EncryptFile(string filename)
        {
            var lines         = Base64.FromFile(new FileInfo(filename));
            var numberOfLines = lines.Length;

            Bytes[] encryptedLines = new Bytes[numberOfLines];

            for (int line = 0; line < numberOfLines; line++)
            {
                encryptedLines[line] = new Bytes(cipher.Encrypt(lines[line].Decode()));
                cipher.ResetNonce();
            }

            return(encryptedLines);
        }