Opc.Ua.Configuration.UserNameCreator.EncryptPassword C# (CSharp) Method

EncryptPassword() private static method

Encrypt Password.
private static EncryptPassword ( byte srcPassword ) : byte[]
srcPassword byte The Source Password.
return byte[]
        private static byte[] EncryptPassword(byte[] srcPassword)
        {
            byte[] encryptedPassword;
            TripleDESCryptoServiceProvider tdes; // Triple DES service provider
            MemoryStream outStream = null;
            CryptoStream encStream = null;
            string dst = string.Empty;

            // Create Triple DES service provider.
            tdes = new TripleDESCryptoServiceProvider();
            // Get encrypt key and initialization vector.
            byte[] key = Encoding.Unicode.GetBytes(strKey);
            byte[] IV = Encoding.Unicode.GetBytes(strIV);

            // Create result stream and encrypt stream.
            using (outStream = new MemoryStream())
            using (encStream = new CryptoStream(outStream, tdes.CreateEncryptor(key, IV), CryptoStreamMode.Write))
            {
                // Encrypt
                encStream.Write(srcPassword, 0, srcPassword.Length);
                encStream.Close();
                encryptedPassword = outStream.ToArray();
            }

            return encryptedPassword;
        }