Skip to content

Instantly share code, notes, and snippets.

View postwait's full-sized avatar

Theo Schlossnagle postwait

View GitHub Profile
@postwait
postwait / hex.js
Created October 30, 2017 19:35 — forked from valentinkostadinov/hex.js
JavaScript HEX encoding
function toHex(s) {
// utf8 to latin1
var s = unescape(encodeURIComponent(s))
var h = ''
for (var i = 0; i < s.length; i++) {
h += s.charCodeAt(i).toString(16)
}
return h
}