public void CanNotDecryptWithIncorrectVector() { RijndaelSymmetricCrypto encryptor = new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "verysalty", 3); const string startingString = "Batman > Superman"; string encrypted = encryptor.Encrypt(startingString); RijndaelSymmetricCrypto decryptor = new RijndaelSymmetricCrypto("password", "rgb init vector!", 8, 8, 256, "verysalty", 3); string decrypted = decryptor.Decrypt(encrypted); Assert.AreNotEqual(startingString, decrypted); }
/// <summary> /// Initializes a new instance of the <see cref="RijndaelSymmetricCryptoSerialized"/> class. /// </summary> /// <param name="configurationFilePath">The configuration file path.</param> public RijndaelSymmetricCryptoSerialized(IFilePath configurationFilePath) { XmlSerializer serializer = new XmlSerializer(typeof(RijndaelSymmetricCryptoConfiguration)); using (Stream stream = configurationFilePath.GetFileStream()) using (XmlTextReader reader = new XmlTextReader(stream)) { RijndaelSymmetricCryptoConfiguration configuration = serializer.Deserialize(reader) as RijndaelSymmetricCryptoConfiguration; this.wrapped = new RijndaelSymmetricCrypto(configuration); } }
public void TestInitialize() { const int minSaltLength = 8; const int maxSaltLength = 8; const int passwordIterations = 3; const int keySize = 256; const string password = "******"; const string rgbInitVector = "EC`MWcW/XT5clpv{"; const string saltValue = "mGE}6;bzYvth$mpL"; this.crypto = new RijndaelSymmetricCrypto(password, rgbInitVector, minSaltLength, maxSaltLength, keySize, saltValue, passwordIterations); }
public void CryptoKeysHaveChanged() { var token = SessionDataSerializer.Serialize(this.Crypto, this.sessionData); RijndaelSymmetricCrypto newCrypto = new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "notverysalty", 3); SessionDataSerializer.Deserialize<SessionData>(newCrypto, token); }
public void EncryptedStringIsNotEqualToInput() { RijndaelSymmetricCrypto rijndaelEnhanced = new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "verysalty", 3); const string startingString = "Batman > Superman"; string encrypted = rijndaelEnhanced.Encrypt(startingString); Assert.AreNotEqual(startingString, encrypted); }
public void DecryptedStringMatchesStartingString() { RijndaelSymmetricCrypto rijndaelEnhanced = new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "verysalty", 3); const string startingString = "Batman > Superman"; string encrypted = rijndaelEnhanced.Encrypt(startingString); string decrypted = rijndaelEnhanced.Decrypt(encrypted); Assert.AreEqual(startingString, decrypted); }
public void TestGenerateKey() { RijndaelSymmetricCrypto encryptor = new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "verysalty", 3); encryptor.GenerateKey(); }
public void TestEncryptAndDecryptStringToByteArray() { RijndaelSymmetricCrypto rijndaelEnhanced = new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "verysalty", 3); const string startingString = "Batman > Superman"; string encryptedString = rijndaelEnhanced.Encrypt(startingString); byte[] decrypted = rijndaelEnhanced.DecryptToBytes(encryptedString); Assert.AreEqual(startingString, Encoding.Default.GetString(decrypted)); }
public void EncryptedStringIsNotNullOrEmpty() { RijndaelSymmetricCrypto rijndaelEnhanced = new RijndaelSymmetricCrypto("password", "rgb init vector.", 8, 8, 256, "verysalty", 3); const string startingString = "Batman > Superman"; string encrypted = rijndaelEnhanced.Encrypt(startingString); Assert.IsFalse(string.IsNullOrEmpty(encrypted)); }