![]() Otherwise, the value of ch is XOR’d with 0xAA in the printf() statement at Line 12, and output as a 2-digit hexadecimal byte. If the end of file is captured at Line 10, the loop halts. Standard input is read at Line 9 and stored in variable ch. The while loop at Lines 7 through 13 is endless. The following code reads text from standard input and outputs a string of hexadecimal bytes encoded with XOR 0xAA. If you XOR 0xAA any byte and then XOR 0xAA the result, you get back the original value. Send those values into another program to decode and retrieve the original text.Īnother example, one I touch upon in my books, is the exclusive OR operation using byte 0xAA, binary 10101010. In all cases, the original data is recovered, which is the point of encoding and decoding.Ī simple example of encoding would be to input a string as text and output that string as its ASCII code values, using either decimal or hex values. As with encoding, you can compress and decompress data, encrypt it or decrypt it, or a mixture of each. While these could be attributes of encoding, they’re not required features. For example, Morse Code translates letters and numbers into dots and dashes.Īt the other end, decoding translates the code created back into its original form, such as taking the dots and dashes and converting them back into readable text.ĭon’t confuse encoding with compression or encryption. DOCEAR WRONG ENCODING HOW TOThis process makes you think about data and how it’s represented, and also how to work on both ends of an input/output puzzle.Įncoding is the process of translating information into another format. A good way to exercise your C programming muscles is to work on a encoding/decoding project. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |