|
Pages: [1]
|
 |
|
Author
|
Topic: Hex Comparing... (Read 864 times)
|
|
Kumash.Kxa™
|
This is a simple HEX comparing script, mostly for WPE'ers... so how it works? first, copy and paste all these codes and paste it on Notepad, then save it as what-ever-name-you-want.html, then you can compare HEX then... just tell me if you encounter an error or wish to suggest something... kumashgore <html> <head> <title></title> </head>
<script language="JavaScript"> <!-- function compare(text1,text2) { len = 0; ctr = 0; str = ''; error = 0; text1val = '<font size="2" face="courier new">'; text2val = '<font size="2" face="courier new">'; if (text1.length >= text2.length) len=text1.length; else len=text2.length; for (x=0; x<len; x++) { if(text1.charAt(x) == text2.charAt(x)) { if (text1.charAt(x) < ' ') if(ctr == 1) { text1val += '<br>'; text2val += '<br>'; ctr = 0; } else ctr++; else text1val += text1.charAt(x); text2val += text2.charAt(x); } else { text1val += '<font style="color:black; background: yellow;"><b>' + text1.charAt(x) + "</b></font>"; text2val += '<font style="color:red; background: yellow;"><b>' + text2.charAt(x) + "</b></font>"; error = 1; } } if(error == 0) alert('Done without errors!'); else document.write('<table width="100%" border=1><tr><td width="50%" valign="top">' + text1val + '</td><td width="50%" valign="top">' + text2val + '</td></tr></table>'); } --> </script>
<body> <form> <textarea name="text1" cols="80" rows="5"></textarea><br><br><textarea name="text2" cols="80" rows="5"></textarea> <br><br> <input type="button" onclick="compare(text1.value,text2.value);" value=" Compare "> </form>
</body> </html>
|
|
|
|
|
Logged
|
|
|
|
|
Shanks
|
Good going... Keep up the good work if u want a rank up 
|
|
|
|
|
Logged
|
|
|
|
|
Kumash.Kxa™
|
Good going... Keep up the good work if u want a rank up ;D [snapback]1199[/snapback] thanks, and i already revised it with Hex subtracting and Hex adding, including Hex to Dec convertion and Dec to Hex convertion as well... ill be uploading it when my cable connection is fixed. kumashgore.
|
|
|
|
|
Logged
|
|
|
|
|
Kumash.Kxa™
|
thanks, and i already revised it with Hex subtracting and Hex adding, including Hex to Dec convertion and Dec to Hex convertion as well... ill be uploading it when my cable connection is fixed. kumashgore. [snapback]1279[/snapback] Finally, here is the revised version... im open to suggestions and commens. <html> <head> <title>All about HEX - by Kumashgore</title> </head>
<script language="JavaScript"> <!-- var hexstr = '0123456789ABCDEF'; function compare(text1,text2) { len = 0; ctr = 0; str = ''; error = 0; text1val = '<font size="2" face="courier new">'; text2val = '<font size="2" face="courier new">'; if (text1.length >= text2.length) len=text1.length; else len=text2.length; for (x=0; x<len; x++) { if(text1.charAt(x) == text2.charAt(x)) { if (text1.charAt(x) < ' ') if(ctr == 1) { text1val += '<br>'; text2val += '<br>'; ctr = 0; } else ctr++; else text1val += text1.charAt(x); text2val += text2.charAt(x); } else { text1val += '<font style="color:black; background: yellow;"><b>' + text1.charAt(x) + "</b></font>"; text2val += '<font style="color:red; background: yellow;"><b>' + text2.charAt(x) + "</b></font>"; error = 1; } } if(error == 0) alert('Done without errors!'); else document.write('<table width="100%" border=1><tr><td width="50%" valign="top">' + text1val + '</td><td width="50%" valign="top">' + text2val + '</td></tr></table>'); } function validatehex(hexval) { if (hexstr.indexOf(hexval.charAt(0)) >= 0) if (hexstr.indexOf(hexval.charAt(1)) >= 0) if (hexval.length == 2) return 1; } function h2dconvert(hexval) { var hexvalue = 0; if (hexstr.indexOf(hexval.charAt(0)) >= 0) hexvalue += hexstr.indexOf(hexval.charAt(0)) * 16; if (hexstr.indexOf(hexval.charAt(1)) >= 0) hexvalue += hexstr.indexOf(hexval.charAt(1)); return hexvalue; } function hextodec(hexval) { if (validatehex(hexval) == 1) alert(hexval + ' = ' + h2dconvert(hexval)); else alert('Please input correct Hex value (ex. 0E)'); } function subhex(hex1, hex2) { if (validatehex(hex1) + validatehex(hex2) == 2) alert(hex1 + '[' + h2dconvert(hex1) + ']' + ' - ' + hex2 + '[' + h2dconvert(hex2) + ']' + ' = ' + (h2dconvert(hex1) - h2dconvert(hex2))); else alert('Please input correct Hex value (ex. 0E)'); } function d2hconvert(hexval) { decvalue = hexstr.charAt(Math.floor(eval(hexval) / 16)) + hexstr.charAt(eval(hexval) % 16); return decvalue; } function dectohex(hexval) { if ((hexval<=255) && (hexval != ' ')) alert(hexval + ' = ' + d2hconvert(hexval)); else alert('Please input number from 0-255.'); } function addhex(hex1, hex2) { if (validatehex(hex1) + validatehex(hex2) == 2) alert(hex1 + '[' + h2dconvert(hex1) + ']' + ' - ' + hex2 + '[' + h2dconvert(hex2) + ']' + ' = ' + (h2dconvert(hex1) + h2dconvert(hex2))); else alert('Please input correct Hex value (ex. 0E)'); } --> </script>
<body> <form> <center> <font size="-1">All about HEX - by Kumashgore</font><br><br> <table border="0" width="50%"> <tr><td align="center"> <textarea name="text1" cols="40" rows="4"></textarea><br><textarea name="text2" cols="40" rows="4"></textarea><br> <input type="button" onclick="compare(text1.value,text2.value);" value="Compare Hex"> <br><br><hr> <table border="0" width="100%"> <tr> <td><input type="text" name="hextodecval" size="2"> <input type="button" onclick="hextodec(hextodecval.value.toUpperCase());" value="Hex to Dec"></td> <td align="right"><input type="text" name="dectohexval" size="2"> <input type="button" onclick="dectohex(dectohexval.value);" value="Dec to Hex"></td> </tr><tr> <td colspan="2"><hr></td> </tr><tr> <td><input type="text" name="subhex1" size="2"> <input type="text" name="subhex2" size="2"> <input type="button" onclick="subhex(subhex1.value.toUpperCase(), subhex2.value.toUpperCase());" value="Subtract Hex"></td> <td align="right"><input type="text" name="addhex1" size="2"> <input type="text" name="addhex2" size="2"> <input type="button" onclick="addhex(addhex1.value.toUpperCase(), addhex2.value.toUpperCase());" value="Add Hex"></td> </tr> </table> </td></tr> </table> </center> </form> </body> </html> kumashgore
|
|
|
|
|
Logged
|
|
|
|
sykescone2
Underoath
Full Member
 
Offline
Posts: 171
Duh... Duh... Duh.....
|
wow... this is good... im still studying about java and C++, this would be a nice sample to learn.. BRAIN FOOD nam nam nam...
|
|
|
|
|
Logged
|
|
|
|
|
Kumash.Kxa™
|
wow... this is good... im still studying about java and C++, this would be a nice sample to learn.. BRAIN FOOD nam nam nam... [snapback]9198[/snapback] thanks... work your way to the UD2, I have posted another stuff there for encypting/decrypting website source... /gg Kumashgore
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |