Reading the thread Easy hide strings from casual viewing of Wayne Diamond I remembered one of my first programs that I wrote. This program was made by requeriment of a computer center manager to obfuscate the payroll file of own computer center in order to hide the information contained to his night operators.
I can remember some details about the method used on this program, was a variation of Vigenère method for EBCDIC code, written with Assembler/360 on card punch, for a IBM main frame. Was in 1967. During the 60's decade this method was considered robust.
Here is the version for ASCII using PB as language. Has a limitation, only is valid for first 127 ASCII characters.
I can remember some details about the method used on this program, was a variation of Vigenère method for EBCDIC code, written with Assembler/360 on card punch, for a IBM main frame. Was in 1967. During the 60's decade this method was considered robust.
Here is the version for ASCII using PB as language. Has a limitation, only is valid for first 127 ASCII characters.
Code:
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' Vigenere.bas by Jordi Vallès version 1a 11/07/2008 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Simple but efective and fast cypher method. Appropriate to hide information to ' operators or employees for prevent casual viewing of some critical information ' like payroll data, personnel files, etc. ' It's based on polyalphabetic substitution. This method is not inteded to ' protect sensitive data to experienced crackers and spies. ' ' This program works only for 127 first ASCII characters. For complete 256 chars ' need some modifications. ' ' Interesting information and history about Blaise de Vigenère (1523-1596) and ' cipher methods based on polyalphabetic substitution can be found on: ' [URL="http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher"]Wikipedia: Vigenère cipher[/URL] and ' [URL="http://en.wikipedia.org/wiki/Polyalphabetic_cipher"]Wkipedia: Polyalphabetic cipher[/URL] ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' - Program developed and tested with PowerBASIC for Windows (PB/Win 8.04) on ' PC HP Pavilion m7760 1.80 GHz with Windows Vista Home Premium. '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' SED_PBWIN #COMPILE EXE "Vigenere.exe" #DIM ALL '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ FUNCTION PBMAIN() AS LONG LOCAL textI, textC, textD, tkey AS STRING textI = "Go placidly amid the noise & haste, and remember what peace there may be in silence. " + _ "As far as possible, without surrender, be on good terms with all persons. Speak your " + _ "truth quietly and clearly; And listen to others, even the dull and ignorant; they too " + _ "have their story." tkey = "This is my Key" CALL Cypher(tkey, textI, textC) CALL DeCypher(tkey, textC, textD) MSGBOX "- Original text:" + $CRLF + textI + $CRLF + $CRLF + _ "- Text Cyphered:" + $CRLF + textC + $CRLF + $CRLF + _ "- Text DeCyphered:" + $CRLF + textD END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ SUB Cypher(keyt AS STRING, text1 AS STRING, text2 AS STRING) LOCAL i, j, k, n AS LONG LOCAL letter AS BYTE PTR letter = STRPTR(text1) text2 = SPACE$(LEN(text1)) 'loop through all characters of the text to be cyphered FOR j = 1 TO LEN(text1) 'get the current character of the key k = ASC(MID$(keyt, j MOD LEN(keyt)+1, 1)) 'get the numeric value of the current key character i = k - 31 'shift the character of the text, rotate if necessary n = @letter + i IF n > 126 THEN n = n - 95 'append to the ciphered string MID$(text2,j) = CHR$(n) INCR letter NEXT j END SUB '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ SUB DeCypher(keyt AS STRING, text1 AS STRING, text2 AS STRING) LOCAL i, j, k, n AS LONG LOCAL letter AS BYTE PTR letter = STRPTR(text1) text2 = SPACE$(LEN(text1)) 'loop through all characters of the encrypted string FOR j = 1 TO LEN(text1) 'get the current character of the key k = ASC(MID$(keyt, j MOD LEN(keyt)+1, 1)) 'get the numeric value of the current key character i = k - 31 'shift the character of the text, rotate if necessary n = @letter - i IF n < 32 THEN n = n + 95 'append to the deciphered string MID$(text2,j) = CHR$(n) INCR letter NEXT j END SUB '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ 'eof
Comment