Doom cheat code encryption

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
Line 29: Line 29:
 
:Well, in m_cheat.c, it's used to build a lookup table which has all the values pre-encrypted, so it can quickly look them up later. Then, when you press a key, it translates it through this table:
 
:Well, in m_cheat.c, it's used to build a lookup table which has all the values pre-encrypted, so it can quickly look them up later. Then, when you press a key, it translates it through this table:
  
:[[File:Doom-cheat-code-encryption-02.png]]
+
:[[File:Doom-cheat-code-encryption-03.png]]
  
 
The thread goes on with more discussion of how they were used and discovered. It's worthwhile reading for people into this sort of trivia.
 
The thread goes on with more discussion of how they were used and discovered. It's worthwhile reading for people into this sort of trivia.

Revision as of 00:56, 3 November 2019

File Format
Name Doom cheat code encryption
Ontology
Released 1993

Doom cheat code encryption was used in the original 1993 version of Doom to make the cheat codes a little harder for hackers to find, so they didn't appear in the raw binary code as plain ASCII characters. (Of course, the hackers found them anyway.) Twitter user @Foone described it in a 2019 thread.

This low-grade encryption is done by shifting the bits of 8-bit numbers (which can represent single ASCII characters) which reverses the order of the bits except for those representing 4 and 32. The shifted values are stored in a lookup table in the Doom program.

Details

As described by @Foone, who has allowed these descriptions to be released as CC0 so they can be used here:

So Doom (1993) has a neat bit of encryption in it. It's not very strong encryption, but it's still encryption.
And it's not used in any sort of way you'd normally expect: not copy protection, or multiplayer anti-cheat, or anti-tampering on saves... It's to slow down FAQs.
So here's the code I'm talking about, the macro SCRAMBLE
It looks annoyingly complicated but it's not, really.
It's taking an 8-bit number and shifting around some of the bits.
Doom-cheat-code-encryption-01.png
If you diagram out what's happening, it makes slightly (BUT ONLY SLIGHTLY) more sense.
It kinda looks like they started with a a "reverse the order of these bits" function but then switched it so the 4 and 32 don't get switched, they just go straight through.
Doom-cheat-code-encryption-02.jpg
So, how is this code used?
Well, in m_cheat.c, it's used to build a lookup table which has all the values pre-encrypted, so it can quickly look them up later. Then, when you press a key, it translates it through this table:
Doom-cheat-code-encryption-03.png

The thread goes on with more discussion of how they were used and discovered. It's worthwhile reading for people into this sort of trivia.

Links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox