private static string EncryptForObscurity(string dataToEncrypt, int randomization)
        {
            if (string.IsNullOrWhiteSpace(dataToEncrypt))
            {
                return(dataToEncrypt);
            }

            byte[] key = RandomStringGenerator.GetBytesFromString(encryptKeyArray[randomization]);
            byte[] iv  = RandomStringGenerator.GetBytesFromString(initVectorArray[randomization]);

            byte[] inputBytes = RandomStringGenerator.GetBytesFromString(dataToEncrypt);

            var des3Encrypt = CreateEncryptor();

            MemoryStream mstream = new MemoryStream();
            CryptoStream cstream = new CryptoStream(mstream, des3Encrypt, CryptoStreamMode.Write);

            cstream.Write(inputBytes, 0, inputBytes.Length);
            cstream.FlushFinalBlock();

            byte[] encryptedDataBytes = mstream.ToArray();

            mstream.Close();
            cstream.Close();

            return(randomization.ToString() + separator + RandomStringGenerator.ToEncodedString(encryptedDataBytes));
        }
        public static string CreateRandomSalt(int saltSize = -1)
        {
            if (saltSize <= -1)
            {
                saltSize = SaltSize;
            }

            byte[] randomBytes           = new byte[saltSize];
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

            rng.GetBytes(randomBytes);
            rng.Dispose();
            string salt = RandomStringGenerator.ToEncodedString(randomBytes);

            return(salt);
        }
        public static string ComputeHash(string password, string salt, SaltMethod saltMethod = SaltMethod.DoubleSalt, HashSize hashSize = HashSize.S160)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new ArgumentNullException("password");
            }
            if (string.IsNullOrWhiteSpace(salt))
            {
                throw new ArgumentNullException("salt");
            }

            string saltedPassword = GetSaltedPassword(password, salt, saltMethod);

            byte[] bytesOfString = RandomStringGenerator.GetBytesFromString(saltedPassword);
            byte[] hash          = ComputeHash(bytesOfString, hashSize);
            return(RandomStringGenerator.ToEncodedString(hash));
        }
        public static string Encrypt(string dataToEncrypt)
        {
            if (string.IsNullOrWhiteSpace(dataToEncrypt))
            {
                return(dataToEncrypt);
            }

            byte[] inputBytes = RandomStringGenerator.GetBytesFromString(dataToEncrypt);

            var des3Encrypt = CreateEncryptor();

            MemoryStream mstream = new MemoryStream();
            CryptoStream cstream = new CryptoStream(mstream, des3Encrypt, CryptoStreamMode.Write);

            cstream.Write(inputBytes, 0, inputBytes.Length);
            cstream.FlushFinalBlock();

            byte[] encryptedDataBytes = mstream.ToArray();

            mstream.Close();
            cstream.Close();

            return(RandomStringGenerator.ToEncodedString(encryptedDataBytes));
        }