Hi,
I'm trying to write a decoder for Yenc, the compression algorithm is as follows:
Code:
1. Fetch a character from the input stream.
2. Increment the character's ASCII value by 42, modulo 256
3. If the result is a critical character (as defined in the previous
section), write the escape character to the output stream and increment
character's ASCII value by 64, modulo 256.
4. Output the character to the output stream.
5. Repeat from start.
So in terms of compression my pseudo code looks something like this:
Code:
Result = (ASCII+42) % 256
If Result == CriticalValue
WriteOut(CriticalValue)
Result = (CriticalValue + 64) % 256
WriteOut(Result)
Now for reversal and getting the orignal ASCII code out I have no idea how to approach it as i don't really understand modulo maths, could anyone lend a hand with some reversal pseudo code?
Thanks alot for any help,.
Jack