public void EncryptECB() { Base64 expected = new Base64(new FileInfo(@"TestFiles\AESEncrypted.txt")); string data = File.ReadAllText(@"TestFiles\AESDecrypted.txt"); AESCipherECB aes = new AESCipherECB(); Base64 result = aes.Encrypt("YELLOW SUBMARINE", data); Assert.AreEqual(expected.ToString(), result.ToString()); }
public void EncryptAndDecryptECB() { Random r = new Random(); byte[] bytes = new byte[r.Next(100)]; r.NextBytes(bytes); string data = new Bytes(bytes).ToString(); string key = "YELLOW SUBMARINE"; AESCipherECB aes = new AESCipherECB(); Base64 encrypted = aes.Encrypt(key, data); string decrypted = aes.Decrypt(key, encrypted); Assert.AreEqual(data, decrypted); }
public string Encrypted(string email) { return(cipher.Encrypt(profiles[email].ToString()).Decode()); }
public Base64 EncryptConsistentKey(string data, Base64 unknownString, int startIndex = 0) { string plaintext = data + unknownString.Decode().Substring(startIndex); return(cipherECB.Encrypt(key.ToString(), plaintext)); }