Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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());
        }