public void TestSaltedDataWithSpecificSize() { Salt s = new Salt(Salt.Size.b64); byte[] testData = new byte[8]; new Random().NextBytes(testData); byte[] tmp; using (SaltedData sd = new SaltedData(s, testData)) { Assert.AreEqual(16, sd.Length); Assert.AreEqual(s, sd.Salt); Assert.AreEqual(testData, sd.GetDataBytes()); tmp = sd.ToArray(); Assert.AreEqual(16, tmp.Length); Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream())); } using (SaltedData sd = new SaltedData(s, new MemoryStream(testData))) { Assert.AreEqual(s, sd.Salt); Assert.AreEqual(testData, sd.GetDataBytes()); Assert.AreEqual(tmp, sd.ToArray()); } using (SaltedData sd = new SaltedData(tmp, Salt.Size.b64)) { Assert.AreEqual(s, sd.Salt); Assert.AreEqual(testData, sd.GetDataBytes()); Assert.AreEqual(tmp, sd.ToArray()); } }
public void TestSaltGetData() { Salt s = new Salt(); byte[] bytes = new byte[1024]; new Random().NextBytes(bytes); SaltedData sd = s.GetData(bytes); Assert.AreEqual(s, sd.Salt); Assert.AreEqual(bytes, sd.GetDataBytes()); sd = s.GetData(new MemoryStream(bytes)); Assert.AreEqual(s, sd.Salt); Assert.AreEqual(bytes, sd.GetDataBytes()); }