System.Text.UnicodeEncoding.GetByteCount C# (CSharp) Method

GetByteCount() private method

private GetByteCount ( char chars, int count ) : int
chars char
count int
return int
        public unsafe override int GetByteCount(char* chars, int count)
        {
            throw null;
        }

Same methods

UnicodeEncoding::GetByteCount ( char chars, int index, int count ) : int
UnicodeEncoding::GetByteCount ( string s ) : int

Usage Example

        public static string HashPassword(string password, string saltValue)
        {
            if (String.IsNullOrEmpty(password)) throw new ArgumentException("Password is null");

            var encoding = new UnicodeEncoding();
            var hash = new SHA256CryptoServiceProvider();

            if (saltValue == null)
            {
                saltValue = GenerateSaltValue();
            }

            byte[] binarySaltValue = Convert.FromBase64String(saltValue);
            byte[] valueToHash = new byte[SaltValueSize + encoding.GetByteCount(password)];
            byte[] binaryPassword = encoding.GetBytes(password);

            binarySaltValue.CopyTo(valueToHash, 0);
            binaryPassword.CopyTo(valueToHash, SaltValueSize);

            byte[] hashValue = hash.ComputeHash(valueToHash);
            var hashedPassword = String.Empty;
            foreach (byte hexdigit in hashValue)
            {
                hashedPassword += hexdigit.ToString("X2", CultureInfo.InvariantCulture.NumberFormat);
            }

            return hashedPassword;
        }
All Usage Examples Of System.Text.UnicodeEncoding::GetByteCount