Q:

Try to convert HashPassword c# (Microsoft example) to javascript

I would like to convert byte.Parse in c# to javascript .. but i am not sure how.
byte[] binarySaltValue = new byte[SaltValueSize];

binarySaltValue[0] = byte.Parse(saltValue.Substring(0, 2), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat);

I need to get the ascII code of the substring(0,2) ... did i am right ?
EDIT QUESTION
The real think i try to do is to convert into Javascript the HashPassword method from Microsoft.
private static string HashPassword(string clearData, string saltValue, HashAlgorithm hash)
        {
            UnicodeEncoding encoding = new UnicodeEncoding();

            if (clearData != null && hash != null && encoding != null)
            {
                // If the salt string is null or the length is invalid then
                // create a new valid salt value.

                // Convert the salt string and the password string to a single
                // array of bytes. Note that the password string is Unicode and
                // therefore may or may not have a zero in every other byte.

                byte[] binarySaltValue = new byte[SaltValueSize];

                binarySaltValue[0] = byte.Parse(saltValue.Substring(0, 2), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat);
                binarySaltValue[1] = byte.Parse(saltValue.Substring(2, 2), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat);
                binarySaltValue[2] = byte.Parse(saltValue.Substring(4, 2), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat);
                binarySaltValue[3] = byte.Parse(saltValue.Substring(6, 2), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat);

                byte[] valueToHash = new byte[SaltValueSize + encoding.GetByteCount(clearData)];
                byte[] binaryPassword = encoding.GetBytes(clearData);

                // Copy the salt value and the password to the hash buffer.

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

                byte[] hashValue = hash.ComputeHash(valueToHash);

                // The hashed password is the salt plus the hash value (as a string).

                string hashedPassword = saltValue;

                foreach (byte hexdigit in hashValue)
                {
                    hashedPassword += hexdigit.ToString("X2", CultureInfo.InvariantCulture.NumberFormat);
                }

                // Return the hashed password as a string.

                return hashedPassword;
            }

            return null;
        }

A:

Ok so there is my solution, maybe it's not optimized but working fine!
 function Salt(plainText, salt) {

        if (plainText != undefined && plainText != "" && salt != null) {
            // If the salt string is null or the length is invalid then
            // create a new valid salt value.

            // Convert the salt string and the password string to a single
            // array of bytes. Note that the password string is Unicode and
            // therefore may or may not have a zero in every other byte.

            var binarySaltValue = new Array();
            binarySaltValue[0] = parseInt(salt.substring(0, 2), 16);
            binarySaltValue[1] = parseInt(salt.substring(2, 4), 16);
            binarySaltValue[2] = parseInt(salt.substring(4, 6), 16);
            binarySaltValue[3] = parseInt(salt.substring(6, 8), 16);
            var binaryPassword = cryptoHelper.stringToBytes(plainText);
            var valueToHash = new Array();
            // Copy the salt value and the password to the hash buffer.
            // binarySaltValue.concat(valueToHash);
            // binarySaltValue.CopyTo(valueToHash, 0);
            // binaryPassword.CopyTo(valueToHash, SaltValueSize);
            valueToHash = valueToHash.concat(binarySaltValue);
            // Détermine la longeur utilisé par le array - 2048
            var newLengthArray = 2048 - valueToHash.length;
            var tampon = new Array(newLengthArray);
            for (var i = 0; i < tampon.length; i++) {
                tampon[i] = 0;
            }
            valueToHash = valueToHash.concat(tampon);
            valueToHash = valueToHash.concat(binaryPassword);
            var hashValue = CryptoJS.MD5(CryptoJS.lib.Base.ByteArray(valueToHash));
            var arr = wordArrayToByteArray(hashValue);
            var hashedPassword = salt;
            for (var i = 0; i < arr.length; i++) {
                hexdigit = arr[i];
                var hexValue = hexdigit.toString(16);
                if (hexValue.length < 2) hexValue = "0" + hexValue;
                hashedPassword += hexValue;
            }
            return hashedPassword;
        }
        return null;
    }

