DECLARE SUB Encrypt (infile$, outfile$, txt$(), tmptxt$(), tmpchange(), encryption(), final()) DECLARE SUB Decrypt (infile$, outfile$, txt$(), tmptxt$(), tmpchange(), encryption(), final()) CLS PRINT "This Program will encrypt/decrypt text files" PRINT "Encrypted files will be SIGNIFIGANTLY larger" PRINT "Path names must follow DOS rules" PRINT "i.e. C:\My Documents\MyNewFile.txt" PRINT "would become C:\mydocu~1\mynewf~1\txt" PRINT "type 'exit' to leave" PRINT "" 3 ON ERROR GOTO 1000 REDIM SHARED txt$(0): REDIM SHARED tmptxt$(0) DIM SHARED tmpchange(1, 1) DIM SHARED encryption(1, 1) DIM SHARED final(1, 1) 1 LINE INPUT "Complete path of input file: ", infile$ IF INSTR(LCASE$(infile$), "exit") THEN END INPUT "Overwrite Existing file? Y/N ", overwrite$ IF INSTR(LCASE$(overwrite$), "exit") THEN END overwrite$ = LCASE$(overwrite$) IF INSTR(overwrite$, "y") THEN outfile$ = infile$ GOTO 2 ELSEIF INSTR(overwrite$, "n") THEN LINE INPUT "Complete path of output file: ", outfile$ IF INSTR(LCASE$(outfile$), "exit") THEN END IF infile$ = outfile$ THEN PRINT "Output file cannot be the same as input file!" GOTO 1 END IF ELSE CLS GOTO 1 END IF 2 LINE INPUT "Encryption or Decryption? E/D?", perform$ IF INSTR(LCASE$(perform$), "exit") THEN END IF INSTR(LCASE$(perform$), "d") THEN CALL Decrypt(infile$, outfile$, txt$(), tmptxt$(), tmpchange(), encryption(), final()) ELSEIF INSTR(LCASE$(perform$), "e") THEN CALL Encrypt(infile$, outfile$, txt$(), tmptxt$(), tmpchange(), encryption(), final()) ELSE PRINT "Error" GOTO 2 END IF GOTO 3 1000 SELECT CASE ERR CASE 11 CLS PRINT "This file cannot be decrypted by this program" GOTO 1 CASE 53 CLS PRINT "File Not found" GOTO 1 CASE 62 RESUME NEXT CASE 64 CLS PRINT "One or more of your file names is invalid" GOTO 1 CASE 76 CLS PRINT "Please make sure all file names are correct AND follow DOS rules " GOTO 1 END SELECT RESUME SUB Decrypt (infile$, outfile$, txt$(), tmptxt$(), tmpchnge(), encryption(), final()) DIM crypt(1, 1) DIM line$(1, 1) LET b = FREEFILE OPEN infile$ FOR INPUT AS b IF outfile$ = infile$ THEN outfile$ = "c:\temp.txt" END IF LET c = FREEFILE OPEN outfile$ FOR APPEND AS c FOR x = 0 TO 1 FOR y = 0 TO 1 INPUT #b, encryption(x, y) NEXT NEXT number = 1 / ((encryption(0, 0) * encryption(1, 1)) - (encryption(0, 1) * encryption(1, 0))) crypt(0, 0) = encryption(1, 1) * number crypt(0, 1) = -encryption(0, 1) * number crypt(1, 0) = -encryption(1, 0) * number crypt(1, 1) = encryption(0, 0) * number DO WHILE NOT EOF(b) LINE INPUT #b, linetochange$ linetochange = VAL(linetochange$) IF z = 0 THEN tmpchange(0, 0) = linetochange ELSEIF z = 1 THEN tmpchange(0, 1) = linetochange ELSEIF z = 2 THEN tmpchange(1, 0) = linetochange ELSEIF z = 3 THEN tmpchange(1, 1) = linetochange final(0, 0) = tmpchange(0, 0) * crypt(0, 0) + tmpchange(1, 0) * crypt(0, 1) final(0, 1) = tmpchange(0, 1) * crypt(0, 0) + tmpchange(1, 1) * crypt(0, 1) final(1, 0) = tmpchange(0, 0) * crypt(1, 0) + tmpchange(1, 0) * crypt(1, 1) final(1, 1) = tmpchange(0, 1) * crypt(1, 0) + tmpchange(1, 1) * crypt(1, 1) FOR x = 0 TO 1 FOR y = 0 TO 1 IF final(x, y) > 1.8 AND final(x, y) < 2.5 THEN final(x, y) = 0 END IF IF final(x, y) > .9 AND final(x, y) < 1.8 THEN PRINT #c, line$ PRINT line$ line$ = "" ELSE line$ = line$ + CHR$(final(x, y)) END IF NEXT NEXT z = -1 END IF z = z + 1 LOOP IF LEN(line$) > 0 THEN PRINT #c, line$ PRINT line$ END IF IF outfile$ = "c:\temp.txt" THEN CLOSE KILL infile$ NAME outfile$ AS infile$ END IF END SUB SUB Encrypt (infile$, outfile$, txt$(), tmptxt$(), tmpchange(), encryption(), final()) LET b = FREEFILE OPEN infile$ FOR INPUT AS b IF outfile$ = infile$ THEN outfile$ = "c:\temp.txt" END IF LET c = FREEFILE OPEN outfile$ FOR APPEND AS c FOR x = 0 TO 1 FOR y = 0 TO 1 7 encryption(x, y) = INT(RND * -50) + INT(RND * -50) IF encryption(x, y) = 0 THEN GOTO 7 END IF PRINT #c, encryption(x, y) NEXT y NEXT x DO WHILE NOT EOF(b) 5 LINE INPUT #b, linetochange$ 6 FOR x = LBOUND(txt$) TO UBOUND(txt$) tmptxt$(x) = txt$(x) NEXT lin = lin + 1 REDIM txt$(lin) linetochange$ = linetochange$ + CHR$(1) txt$(lin) = linetochange$ FOR x = LBOUND(tmptxt$) TO UBOUND(tmptxt$) txt$(x) = tmptxt$(x) NEXT REDIM tmptxt$(lin) IF lin = 30 THEN GOTO 4 LOOP IF EOF(b) <> 0 AND looped = 0 THEN linetochange$ = "End of File" looped = 1 GOTO 6 END IF 4 FOR x = 0 TO lin FOR y = 1 TO LEN(txt$(x)) LET tmp$ = LEFT$(txt$(x), y) LET change$ = RIGHT$(tmp$, 1) IF change$ = " " OR change$ = "" THEN LET change$ = CHR$(2) change% = ASC(change$) IF z = 0 THEN tmpchange(0, 0) = change% ELSEIF z = 1 THEN tmpchange(0, 1) = change% ELSEIF z = 2 THEN tmpchange(1, 0) = change% ELSEIF z = 3 THEN tmpchange(1, 1) = change% final(0, 0) = tmpchange(0, 0) * encryption(0, 0) + tmpchange(1, 0) * encryption(0, 1) final(0, 1) = tmpchange(0, 1) * encryption(0, 0) + tmpchange(1, 1) * encryption(0, 1) final(1, 0) = tmpchange(0, 0) * encryption(1, 0) + tmpchange(1, 0) * encryption(1, 1) final(1, 1) = tmpchange(0, 1) * encryption(1, 0) + tmpchange(1, 1) * encryption(1, 1) PRINT #c, final(0, 0) PRINT #c, final(0, 1) PRINT #c, final(1, 0) PRINT #c, final(1, 1) z = -1 END IF z = z + 1 NEXT y NEXT x IF lin = 30 AND EOF(b) = 0 THEN lin = 0 REDIM txt$(lin) REDIM tmptxt$(lin) GOTO 5 END IF PRINT "File Encrypted" IF outfile$ = "c:\temp.txt" THEN CLOSE KILL infile$ NAME outfile$ AS infile$ ELSE 8 INPUT "Delete original file? Y/N ", delold$ delold$ = LCASE$(delold$) IF INSTR(delold$, "y") THEN KILL infile$ ELSEIF INSTR(delold$, "n") THEN ELSE GOTO 8 END IF END IF PRINT "" END SUB