public bool IsAdmin(Base64 encrypted)
        {
            string values   = cipher.Decrypt(key, encrypted, iv);
            string adminKey = "admin";

            ValuePairParser dictionaryManager = new ValuePairParser(values, ';');

            return(dictionaryManager.Contains(adminKey) && dictionaryManager[adminKey] == "true");
        }
        public void DecryptCBC()
        {
            string expected = File.ReadAllText(@"TestFiles\AESDecrypted.txt");
            Base64 data     = new Base64(new FileInfo(@"TestFiles\AESCBCEncrypted.txt"));
            string iv       = new string('\0', blockSize);

            AESCipherCBC aes    = new AESCipherCBC();
            string       result = aes.Decrypt("YELLOW SUBMARINE", data, iv);

            Assert.AreEqual(expected, result);
        }
        public void EncryptAndDecryptCBC()
        {
            Random r = new Random();

            byte[] bytes = new byte[r.Next(100)];
            r.NextBytes(bytes);

            string data = new Bytes(bytes).ToString();
            string key  = "YELLOW SUBMARINE";

            string iv = new String('\0', blockSize);

            AESCipherCBC aes       = new AESCipherCBC();
            Base64       encrypted = aes.Encrypt(key, data, iv);
            string       decrypted = aes.Decrypt(key, encrypted, iv);

            Assert.AreEqual(data, decrypted);
        }
Exemplo n.º 4
0
 public void ReceiveEncryptedCookie(Hex data, string iv)
 {
     decrypted = cipherCBC.Decrypt(key, data, iv);
 }