.TITLE CRYPT - In-place encrypt (or decrypt) input string .IDENT /V1.12/ .REM | *+ CRYPT - In-place encrypt (or decrypt) input string File:CRYPT.MAC Version: V1.12 Author: Jim Bostwick 13-FEB-1985 Last Edit: 29-MAY-1985 14:38:29 Last Update: 29-May-1985 14:38:49 psect boundary fix *- | .LIBRARY /LB:[1,1]GLMAC.MLB/ .MCALL EXIT$S,PUSH,POP .SBTTL LOCAL DATA .PSECT DATA,D,rw,gbl,con .ascii /Ilyatoujourslaquestiondel'ordinateurs.Est-cec/ .even key: .ascii /'estmeuilleursd'acheterunordinateurIBMouunordinateur/ .ascii /DEC.IBMestlenomleplusconnuedanslamonde.Aumemetemps,/ .ascii /c'estDEC,quiestlaplusflexibleetefficace.Nous,chez/ .ascii /Grain Lab,ontchoisilesordinateursDEC./ .even .PSECT .SBTTL CRYPT - Encrypt input string .REM | Crypt performs a simple, in-place encryption of the input string. The algorithm is the familiar and relatively insecure XOR of data bytes with a key text. This works for crypt because the key is guaranteed to be longer than the input text, and the messages are relatively short. Both combine to frustrate normal breaking techniques. If r0 is odd, the first character of the key is skipped, resulting in word alignment for most of the routine. CALL jsr pc, CRYPT INPUT r0 -> input string r1 = length of input string OUTPUT input string encrypted in place REGS all preserved | CRYPT:: call $saval ; save all registers mov #key, r2 ; point to key loop: movb (r0), r4 ; get data byte movb (r2)+, r3 ; get key byte xor r3, r4 ; scramble movb r4, (r0)+ ; and put back sob r1,loop ; reduce byte count, and loop 30$: return ; $SAVAL restores registers .END