Пример #1
0
        public void opEquality_Salt_SaltFalse()
        {
            var obj = new Salt("XbAH5ybjSkZt+Q==");
            var comparand = new Salt();

            Assert.False(obj == comparand);
        }
Пример #2
0
        public void opEquality_Salt_SaltSame()
        {
            var obj = new Salt("XbAH5ybjSkZt+Q==");
            var comparand = obj;

            Assert.True(obj == comparand);
        }
Пример #3
0
        public static SecureHash Encrypt(string plaintext,
                                         Salt salt)
        {
            if (null == plaintext)
            {
                throw new ArgumentNullException("plaintext");
            }

            if (null == salt)
            {
                throw new ArgumentNullException("salt");
            }

            var bytes = new byte[plaintext.Length + salt.ToBytes().Length];
            Encoding.UTF8.GetBytes(plaintext).CopyTo(bytes, 0);
            salt.ToBytes().CopyTo(bytes, plaintext.Length);

            SecureHash result;
            using (HashAlgorithm algorithm = new SHA256Managed())
            {
                result = new SecureHash(algorithm.ComputeHash(bytes));
            }

            return result;
        }
Пример #4
0
        public void opEquality_Salt_SaltTrue()
        {
            const string value = "XbAH5ybjSkZt+Q==";

            var obj = new Salt(value);
            var comparand = new Salt(value);

            Assert.True(obj == comparand);
        }
Пример #5
0
        public void opImplicit_Salt_string()
        {
            const string value = "XbAH5ybjSkZt+Q==";

            var expected = new Salt(value);
            Salt actual = value;

            Assert.Equal(expected, actual);
        }
Пример #6
0
        public void op_ToString()
        {
            const string expected = "XbAH5ybjSkZt+Q==";
            var actual = new Salt(expected).ToString();

            Assert.Equal(expected, actual);
        }
Пример #7
0
        public void op_GetHashCode()
        {
            const string value = "XbAH5ybjSkZt+Q==";

            var expected = value.GetHashCode();
            var actual = new Salt(value).GetHashCode();

            Assert.Equal(expected, actual);
        }
Пример #8
0
        public void op_Equals_objectTrue()
        {
            const string value = "XbAH5ybjSkZt+Q==";
            var obj = new Salt(value);
            var comparand = new Salt(value);

            Assert.True(obj.Equals(comparand));
        }
Пример #9
0
        public void op_Equals_objectString()
        {
            const string value = "XbAH5ybjSkZt+Q==";
            var obj = new Salt(value);

            Assert.False(obj.Equals(value));
        }
Пример #10
0
        public void op_Equals_objectSame()
        {
            var obj = new Salt();
            var comparand = obj;

            Assert.True(obj.Equals(comparand));
        }
Пример #11
0
        public void op_Equals_objectFalse()
        {
            var obj = new Salt();
            var comparand = new Salt("XbAH5ybjSkZt+Q==");

            Assert.False(obj.Equals(comparand));
        }
Пример #12
0
        public void opInequality_Salt_SaltTrue()
        {
            var obj = new Salt("XbAH5ybjSkZt+Q==");
            var comparand = new Salt();

            Assert.True(obj != comparand);
        }
Пример #13
0
        public void opInequality_Salt_SaltSame()
        {
            var obj = new Salt("XbAH5ybjSkZt+Q==");
            var comparand = obj;

            Assert.False(obj != comparand);
        }
Пример #14
0
        public void opInequality_Salt_SaltFalse()
        {
            const string value = "XbAH5ybjSkZt+Q==";

            var obj = new Salt(value);
            var comparand = new Salt(value);

            Assert.False(obj != comparand);
        }
Пример #15
0
        public void opImplicit_string_Salt()
        {
            const string expected = "XbAH5ybjSkZt+Q==";
            string actual = new Salt(expected);

            Assert.Equal(expected, actual);
        }