How can I break REDSHIRT / REDSHIRT2 encryption? Recently, a user on Gaming.SE asked a question about whether the user password in the video game Uplink could be modified after being initially set.  The game does not contain an option to change the password, and the password is repeatedly displayed in plain text throughout in the game.  Obviously, this is a problem if a user accidentally uses a valuable password.

The game stores the password in the save file, which could be edited, except that the save file is encrypted using Introversion's REDSHIRT encryption scheme.  How do the REDSHIRT and REDSHIRT2 encryption schemes work, and what is the decryption algorithm?



Be Aware: Details of REDSHIRT encryption have already been discovered and published:


http://www.mario-konrad.ch/index.php?page=14002
http://uplinkfan.blogspot.com/2011/10/getting-book-2-of-uplink-game-bible.html


I'm asking this question only to benefit future users.  I do plan to post my own answer, but I'll be happy to upvote and accept anyone who explains it better than I can.
I'm not going to explain this but after looking at redshirt.c; the core part of the program is that after skipping the header (which is "REDSHIRT" (9 bytes includes an ending null byte)), it has a loop which does:

int j;
j = (j &amp; 0x7F) + (~j &amp; 0x80);


Which, if you don't recognize it, maps 128-255 to 0-127 and 0-127 to 128-255. (I think this might be the same as swapping the nibbles of a byte.) and is the same as j = (j + 128) % 256.