public void CombineBytes()
        {
            byte[] test1 = new byte[] { 0, 1, 2, 3 };
            byte[] test2 = new byte[] { 0, 1, 2, 3 };

            byte[] combinedBytes = CryptographyUtility.CombineBytes(test1, test2);
            Assert.AreEqual(test1.Length + test2.Length, combinedBytes.Length);
        }
        public void CombineBytes()
        {
            byte[] first  = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            byte[] second = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };

            byte[] expected = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
            byte[] actual   = CryptographyUtility.CombineBytes(first, second);

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        /// <summary>
        /// Creates the hash bytes.
        /// </summary>
        /// <param name="plainTextPassword">The plain text password.</param>
        /// <param name="salt">The salt.</param>
        /// <returns>System.Byte[].</returns>
        protected virtual byte[] CreateHashBytes(byte[] plainTextPassword, byte[] salt = null)
        {
            if (salt == null)
            {
                salt = new byte[SaltLength];
                using (var rngCsp = new RNGCryptoServiceProvider())
                {
                    rngCsp.GetNonZeroBytes(salt);
                }
            }

            var rfc2898DeriveBytes = new Rfc2898DeriveBytes(plainTextPassword, salt, 1000);
            var hash = rfc2898DeriveBytes.GetBytes(20);

            return(CryptographyUtility.CombineBytes(salt, hash));
        }