Has a problem when I try to process a non-ASCII byte!

I am working on a file encrypter program. A bug occured when I try to process some non-string file, like .exe or something. So obviously, not every byte in a .exe is a character. So here comes a problem.

Let me show you two pictures. I rename the .exe into .txt and open it, here is what I saw.


Before encrypting: You can see the string “This program cannot be run in DOS mode” in the top line.


After be decrypted: You still can see the string, but obviously the other part of the file is changed.

Here is what I see when I debug. This bunch of numbers indicates the very 14 bytes of a file.

Before: 77 90 144 0 3 0 0 0 4 0 0 0 255 255 0

After: 77 90 144 255 2 255 255 255 3 255 255 255 254 254 255

So obviously, the first 3 characters are well protected(I think they are exactly the M Z and ? in the picture above), but others are not. The “after” bytes are more like have a -1. Why such problems happen?

Thank you.

submitted by /u/Teslawu
[link] [comments]

Leave a Reply