System.Net.SecureOnPassword.SecureOnPassword C# (CSharp) Method

SecureOnPassword() public method

Initializes a new instance of SecureOnPassword with the given password.
is null. is null. The array wich is created using the password has more elements than 6.
public SecureOnPassword ( string password, Text encoding )
password string The password as .
encoding Text The instance to use for the password.
        public SecureOnPassword(string password, Text.Encoding encoding)
        {
            if (password == null)
                throw new ArgumentNullException(nameof(password));
            if (encoding == null)
                throw new ArgumentNullException(nameof(encoding));

            if (string.IsNullOrEmpty(password))
                _password = new byte[6];

            var bytes = encoding.GetBytes(password);
            if (bytes.Length > 6)
                throw new ArgumentException(Localization.ArgumentExceptionInvalidPasswordLength);

            _password = new byte[6];
            for (int i = 0; i < bytes.Length; i++)
                _password[i] = bytes[i];
            if (bytes.Length < 6)
            {
                for (int i = bytes.Length - 1; i < 6; i++)
                    _password[i] = 0x00;
            }
        }

Same methods

SecureOnPassword::SecureOnPassword ( byte password )
SecureOnPassword::SecureOnPassword ( string password )