Skip to content

Instantly share code, notes, and snippets.

View hcortezr's full-sized avatar

Cortez hcortezr

  • Nevada
  • 11:19 (UTC -07:00)
View GitHub Profile
@don
don / hexStringToArrayBuffer.js
Created May 3, 2018 17:54
Convert hex string to ArrayBuffer
/**
* Convert a hex string to an ArrayBuffer.
*
* @param {string} hexString - hex representation of bytes
* @return {ArrayBuffer} - The bytes in an ArrayBuffer.
*/
function hexStringToArrayBuffer(hexString) {
// remove the leading 0x
hexString = hexString.replace(/^0x/, '');