Computer Ciphering

The advent of computing has been a two edged sword for cryptology. On one hand, encrypting a message and hiding your secrets is no longer an arduous task. On the other hand decrypting messages and someone discovering your secrets is no longer an arduous task.

Below is a sample program which aids in encryption. BASIC syntax has been used, but can be converted to anything else. This will do additive, multiplicative and affine encryption. If you want an additive scheme set the multiplicative key to one, if you want an multiplicative scheme then set the additive key to zero. A similar program is easily written for decryption (do multiplication by the inverse first and the addition by the inverse) or any other encryption technique.

Affine Cipher Code

CLS

'get message and keys

INPUT "Message: ", Mess$

INPUT "Additive key: ", iAddKey

INPUT "Multiplicative key: ", iMultKey

iStrLen = LEN(Mess$)

FOR lictr = 1 TO iStrLen

        'read off next message character

        NextChar$ = MID$(LCASE$(Mess$), lictr, 1)

        iNextChar = ASC(NextChar$) - 96

 

        'if next char is a lower case letter, then encrypt it

        IF iNextChar > 0 AND iNextChar < 27 THEN

                iCount = iCount + 1

                iAddShiftChar = (iNextChar + iAddKey) MOD 26

                iShiftChar = (iAddShiftChar * iMultKey) MOD 26 + 96

 

                'double check letter is in right position

                IF iShiftChar < 97 THEN iShiftChar = iShiftChar + 26

                IF iShiftChar > 122 THEN iShiftChar = iShiftChar - 26

                ShiftChar$ = CHR$(iShiftChar)

                PRINT ShiftChar$;

         END IF

NEXT lictr

 

This booklet includes a diskette which has windows based software for encrypting or decrypting using additive, multiplicative, affine and Vigenere square methods. You should be able to run it straight off of the floppy or by copying it to a hard drive. There are ten sample messages to practice decrypting on the decryption page.