diff --git a/Scripts/ASCIIToHex.js b/Scripts/ASCIIToHex.js new file mode 100644 index 00000000..bb86f5af --- /dev/null +++ b/Scripts/ASCIIToHex.js @@ -0,0 +1,20 @@ +/** + { + "api":1, + "name":"ASCII To Hex", + "description":"Converts ASCII characters to hex", + "author":"aWZHY0yQH81uOYvH", + "icon":"metamorphose", + "tags":"ascii,hex,convert" + } +**/ + +function main(state) { + buf = ""; + for(i = 0; i < state.fullText.length; i ++) { + code = state.fullText.charCodeAt(i).toString(16); + if(code.length < 2) buf += "0"; + buf += code; + } + state.fullText = buf.toUpperCase(); +} \ No newline at end of file diff --git a/Scripts/HexToASCII.js b/Scripts/HexToASCII.js new file mode 100644 index 00000000..dd622582 --- /dev/null +++ b/Scripts/HexToASCII.js @@ -0,0 +1,28 @@ +/** + { + "api":1, + "name":"Hex To ASCII", + "description":"Converts hex into ASCII characters", + "author":"aWZHY0yQH81uOYvH", + "icon":"metamorphose", + "tags":"hex,ascii,convert" + } +**/ + +function main(state) { + input = state.fullText.toUpperCase(); + buf = ""; + hexBuf = ""; + for(i = 0; i < input.length; i ++) { + c = input.charAt(i); + if("0123456789ABCDEF".includes(c)) { + hexBuf += c; + if(hexBuf.length >= 2) { + buf += String.fromCharCode(parseInt(hexBuf, 16)); + hexBuf = ""; + } + } else if(c != ' ' && c != '\t' && c != '\n' && c != '\r') + throw "Not hex"; + } + state.fullText = buf; +} \ No newline at end of file