| Viewing Single Post From: Urrrgh! Help Plz | |
|---|---|
| jdege | Mar 7 2007, 01:54 PM |
|
Elite member
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
There's nothing wrong with your C. Well, there's a lot wrong with your C - K&R bracing, screwy indents, use of obsolete modifiers like "register" and "inline", but none of that has anything to do with why your code isn't working. Your problem is your use of the "last" variable in decrypt. Remember your formulas:
When you're encrypting, you have "last" storing the last output character, C[n-1]. When you're decrypting, you have "last" storing the last output character, P[n-1]. But in decrypt, you're supposed to XOR the previous ciphertext character, not the previous plaintext character. In decrypt, "last" should be set to the "current_byte", after you've decrypted "current_byte" and before you do the next fgetc(). |
| When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. | |
![]() |
|
| Urrrgh! Help Plz · Off-topic | |




![]](http://209.85.122.85/static/1/pip_r.png)


10:40 AM Nov 25