CRACK Solution

Single Key

CRACK single-key XOR cipher

In-game screenshot of Single Key
In-game view
FamilyCRACK Graph0.236 DifficultyEasy Ring02 IDz1_xor_key

Prerequisites

STALE SUM

Unlocks

BACKBEAT

Accepted input dojo
Techniquesingle-key XOR cipher Rulenonzero Sampledojo

Walkthrough

Recover the accepted input below, then submit it to the CRACK verifier.

Reject Samples

  • doj
  • dojoX
  • DOJO
  • dojp
Verifier Listing
; z1_xor_key: Single Key. A classic single-key XOR cipher: every input byte is
; XOR'd with the same constant key 0x42 and compared to a stored array. XOR is
; its own inverse, so XOR each stored byte with the key to recover the answer.
; r0 = 1 on accept (nonzero rule).
;
; enc = { 0x26, 0x2d, 0x28, 0x2d }; each ^ 0x42 -> "dojo". Length must be 4.
; Answer: dojo

        len   r1
        cmp   r1, 4
        jnz   bad           ; length must be exactly 4

        mov   r7, 0
        ldb   r0, [r7]
        xor   r0, 0x42
        cmp   r0, 0x26      ; 'd'
        jnz   bad
        inc   r7
        ldb   r0, [r7]
        xor   r0, 0x42
        cmp   r0, 0x2d      ; 'o'
        jnz   bad
        inc   r7
        ldb   r0, [r7]
        xor   r0, 0x42
        cmp   r0, 0x28      ; 'j'
        jnz   bad
        inc   r7
        ldb   r0, [r7]
        xor   r0, 0x42
        cmp   r0, 0x2d      ; 'o'
        jnz   bad

        mov   r0, 1
        ret
bad:    mov   r0, 0
        ret