Saturday, 15 March 2014

python - How to Apply Reverse Logic for Decoding? -


I'm on the last part of a decoding python exercise, and it's really confusing me, encoding 376 to 65 9 12 The word denotes three characters: the first character is always (0xFA), the second is ((code-376) // 256), and the third is ((code-376%% 256). For example, if the code is 30000, then the first output letter will be 0xFA, second 0x73, and the third 0xB8. (The code of 376 will be FA 00 00).

Now my illusion is, how can I explain 0xfa 0x73 0xb8 as 30000? Because this word will be 30000th word for my dictionary Any help would be greatly appreciated, thanks.

See the first letter, if it is 0xFA,

code = Second * 256 + third + 376


No comments:

Post a Comment