예제 #1
0
 /// <summary> Compares the hash </summary>
 public override int CompareTo(PasswordHash other)
 {
     if (((object)other) == null)
     {
         return(1);
     }
     return(BinaryComparer.Compare(_hash.ToArray(), other._hash.ToArray()));
 }
예제 #2
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());
            }
        }