public void EncryptedStringEqualityTests() { EncryptedString nullString = null; var empty = new EncryptedString(); var encryptedA = Encrypt(ClearText); var encryptedB = Encrypt(ClearText); var encryptedC = Encrypt(ClearText.ToLowerInvariant()); Assert.IsFalse(ReferenceEquals(nullString, empty)); Assert.IsFalse(ReferenceEquals(nullString, encryptedA)); Assert.IsFalse(ReferenceEquals(nullString, encryptedB)); Assert.IsFalse(ReferenceEquals(empty, encryptedA)); Assert.IsFalse(ReferenceEquals(empty, encryptedB)); Assert.IsFalse(ReferenceEquals(encryptedA, encryptedB)); Assert.IsTrue(nullString != empty); Assert.IsTrue(nullString != encryptedA); Assert.IsTrue(empty != nullString); Assert.IsTrue(encryptedA != nullString); Assert.IsTrue(empty != encryptedA); Assert.IsTrue(encryptedA != empty); Assert.IsTrue(encryptedA == encryptedB); Assert.IsTrue(encryptedA != encryptedC); Assert.AreEqual <object>(encryptedA, encryptedB); Assert.AreEqual <object>(encryptedA, encryptedB.ToArray()); Assert.AreEqual <object>(encryptedA, encryptedB.ToString()); Assert.AreNotEqual <object>(encryptedA, empty); Assert.AreNotEqual <object>(encryptedA, empty.ToArray()); Assert.AreNotEqual <object>(encryptedA, empty.ToString()); Assert.AreNotEqual <object>(encryptedA, 5); }
public static DecryptingStreamWriter Write(EncryptedString stream, PrivateKey key) => Write(new MemoryStream(stream.ToArray()), key);
public async Task WriteAsync(EncryptedString text) => await WriteDataAsync(text.ToArray());
public static DecryptingStreamReader Read(EncryptedString stream, PrivateKey key) => Read(new MemoryStream(stream.ToArray()), key);