forked from gratajik/Hex0r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hex0r.min.js
1 lines (1 loc) · 2.99 KB
/
hex0r.min.js
1
function dec2_to_hex(t) { return 0 > t && (t = 0), t > 255 && (t = 255), HEX.charAt(Math.floor(t / 16)) + HEX.charAt(t % 16) } function dec_to_hex8(t) { for (var a = "", e = 3; e >= 0; e--) a += dec2_to_hex(t >> 8 * e & 255); return a } function remove_whitespace(t) { return t.replace(/\n/g, "").replace(/\t/g, "").replace(/ /g, "").replace(/\r/g, "") } function base64_decode(t) { for (var a = "", e = 0; e < t.length; e += 4) { var r = t.charAt(e + 0), d = t.charAt(e + 1), n = t.charAt(e + 2), o = t.charAt(e + 3), l = BASE64_CHARS.indexOf(r), s = BASE64_CHARS.indexOf(d), i = BASE64_CHARS.indexOf(n), h = BASE64_CHARS.indexOf(o); a += String.fromCharCode(l << 2 | s >> 4), a += String.fromCharCode((15 & s) << 4 | i >> 2), a += String.fromCharCode((3 & i) << 6 | h) } return a } function markup_hex0rwindow(t) { function a(a) { for (var e = 0; e < p.length; e++) a >= p[e][0] && a <= p[e][1] ? (a == p[e][0] && $("table tr td:last", t).addClass("hex0rwindow_border_start"), a == p[e][1] && $("table tr td:last", t).addClass("hex0rwindow_border_end"), $("table tr td:last", t).addClass("hex0rwindow_code_hi hex0rwindow_border_middle"), $("table tr td:last", t).attr("style", "backround-color: " + p[e][2] + ";"), $("table tr td:last", t).attr("title", p[e][3]), b += 1) : $("table tr td:last", t).addClass("hex0rwindow_code") } var e = parseInt($(t).data("row-width")), r = parseInt($(t).data("word-size")), d = parseInt($(t).data("row-break")), n = $(t).data("caption"), o = $(t).data("highlights").split(","), l = "true" == $(t).data("trim").toString(), s = "true" == $(t).data("base64").toString(), i = "true" == $(t).data("show-line-nums").toString(), h = t.text(); 1 == l && (h = remove_whitespace(h)), 1 == s && (h = base64_decode(h)); for (var c, p = [], _ = 0; _ < o.length; _++) p.push(o[_].split(":")); t.text(""), t.append("<table></table>"); var w = 0; for (n && $("table", t).append("<caption>" + n + "</caption>"); h.length > 0; ) { c = h.slice(0, e), h = h.slice(e), $("table", t).addClass("hex0rwindow_table"), $("table", t).append("<tr></tr>").addClass("hex0rwindow"), 1 == i && ($("table tr:last", t).append("<td>" + dec_to_hex8(w) + " </td>"), $("table tr td:last", t).addClass("hex0rwindow_offset")); for (var b = 0, f = 0; f < c.length; f += r) { for (var x = "", u = 0; r > u; u++) x += dec2_to_hex(c.charCodeAt(f + u)); f == d - 1 ? ($("table tr:last", t).append("<td>" + x + "  </td>"), a(w + f)) : ($("table tr:last", t).append("<td>" + x + " </td>"), a(w + f)) } for (var C = "", g = 0; g < c.length; g++) { var A = c.charCodeAt(g); C += A >= 32 && 126 >= A ? c.charAt(g) : "." } c.length < e && $("table tr td:last", t).attr("colspan", Math.floor((e - c.length) / r) + 1), w += e, $("table tr:last", t).append("<td>" + C + "</td>"), $("table tr td:last", t).addClass("hex0rwindow_visual") } } var HEX = "0123456789ABCDEF", BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; $(document).ready(function () { $("div.hex0rwindow").each(function (t) { markup_hex0rwindow($(this), t) }) });