Recently I’ve been thinking a lot about data on the lower-level of the stack, this is the area where data stops being simple strings and starts looking more like random numbers, *e.g. (59:6f:75:20:63:72:61:63:6b:65:64:20:74:68:65:20:63:6f:64:65:21)
I’ve been wondering a lot about this data, because I do a lot of server communication with my applications, knowing encoding should come in handy!
So a couple of ideas brewing up inside, such as my own compression algorithms, encryption algorithms and also plans to learn low level languages.
I thought I would share the code I’ve been playing with.
var letter = "A" // Always decimal 65 in ASCII
var byteCode = letter.charCodeAt(0); // Get the byteCode (decimal) = 65
var character = String.fromCharCode(byteCode); // Return ASCII character/symbol
var binaryCode = byteCode.toString(2); // Convert to base 2 (Binary)
var hexCode = character.charCodeAt(0).toString(16); // Convert to base 16 (Hexadecimal)
console.log(character+" "+byteCode+" 0x"+hexCode+" "+binaryCode);
Thanks to Rezoner for comments! On using toString which I understand now!
Demo of this code in use can be viewed here:
All source can be duplicated, sold, expanded upon, published or used at your own risk and you accept that there may be inaccuracies, you agree I am not responsible for any damages implementing this code could cause.
*If you crack the code let me know in comment!