String to byte array
<p>I have to convert a string to byte (16 bit) in JavaScript. I can do this in .net in following code but I have to change this for old classic asp App which uses JavaScript.</p>

<pre><code>string strShared_Key = "6fc2e550abc4ea333395346123456789";
int nLength = strShared_Key.Length;
byte[] keyMAC = new byte[nLength / 2];
for (int i = 0; i &lt; nLength; i += 2)
    keyMAC[i / 2] = Convert.ToByte(strShared_Key.Substring(i, 2), 16);
</code></pre>

<p>This is the JavaScript function but doesn't return same out put as above .net code.</p>

<pre><code>function String2Bin16bit(inputString) {
        var str = ""; // string 
        var arr = [];       // byte array 
        for (var i = 0; i &lt; inputString.length; i += 2) {
            // get chunk of two characters and parse to number 
            arr.push(parseInt(inputString.substr(i, 2), 16));
        }
        return arr;
    }
</code></pre>
