stringToArrayBuffer = function(string) {
  var buffer = new ArrayBuffer(string.length);
  var bufferView = new Uint8Array(buffer);
  for (var i = 0; i < string.length; i++) {
    bufferView[i] = string.charCodeAt(i);
  }
  return buffer;
}
Convert a string to an ArrayBuffer.
@param {string} string The string to convert.
@return {ArrayBuffer} An array buffer whose bytes correspond to the string.