SUB Encrypt3 (FileName$, Password$) ' +-----------------------------------------------------+ ' | | ' | WARNING WARNING WARNING | ' | ------- ------- ------- | ' | This encryption routine may only be used for ASCII text files! | ' | | ' +-------------------------------------------------------------------+ ' +--------------------------------------------------------------------+ ' | | ' | - S U B E n c r y p t 3 - | ' | | ' | | ' | Public Domain - FreeWare | ' +--------------------------------------------------------------------+ ' +--------------------------------------------------------------------+ ' | - ABOUT THE AUTHOR - | ' +--------------------------------------------------------------------+ ' | | ' | Hello. My name is Don Smith and I am a thirty-year retired teacher | ' | of Math/History/Spanish residing in Orange County, California. I | ' | am also a former six-year Sergeant of Marines. Who-Rah! On certain | ' | forums I am known as MarineDon.My email is: smithdonb@earthlink.net| ' | | ' +--------------------------------------------------------------------+ ' | - COPYING AND DISTIBUTING - | ' +--------------------------------------------------------------------+ ' | Since this code is public domain and freeware, anyone may freely | ' | copy and distribute it. If you use the QuickBasic code in one of | ' | your own programs, you do not have to cite my name as the author, | ' | and you may even change its name. | ' +--------------------------------------------------------------------+ ' +--------------------------------------------------------------------+ ' | SUB Encrypt3 was written with QuickBASIC 4.5, a DOS programming | ' | language. SUB Encrypt3 was designed to encrypt and deencrypt | ' | DOS text files. DO NOT attempt to use with other files or programs | ' | such as executable programs ending in .EXE as this encryption | ' | routine will destroy them. ASCII text files only! | ' +--------------------------------------------------------------------+ ' +--------------------------------------------------------------------+ ' | +-------------+ ' ' | | DISCLAIMER | ' ' | +-------------+ ' ' | The author of this SUB Encrypt3 accepts no liability for damages ' ' | resulting from its use or misuse. In addition, in opening and ' ' | using SUB Encrypt3 the computer user accepts it in an "as is" ' ' | condition and further accepts total responsibility for it and ' ' | its use. ' ' +--------------------------------------------------------------------+ LenOfKey% = LEN(key$) InCharByte$ = SPACE$(1) Keylocation& = 1 TempFile$ = "FileDump.Txt" OPEN FileName$ FOR INPUT AS #9 LINE INPUT #9, Soso$ Soso$ = RTRIM$(LTRIM$(Soso$)) IF LEFT$(Soso$, 9) = "Encrypted" THEN Encry% = 1 END IF CLOSE #9 OPEN FileName$ FOR INPUT AS #1 OPEN TempFile$ FOR OUTPUT AS #2 IF Encry% = 0 THEN PRINT #2, "Encrypted File. Any attempts to unlock will destroy the file." ELSEIF Encry% = 1 THEN LINE INPUT #1, ThrowAway$ END IF DO IF EOF(1) THEN EXIT DO LINE INPUT #1, InputLine$ FOR CheckLine% = 1 TO LEN(InputLine$) InCharByte$ = MID$(InputLine$, CheckLine%, 1) IF InCharByte$ = "" THEN InCharByte$ = "%" IF Encry% = 1 THEN AltAsc% = ASC(InCharByte$) - ASC(MID$(PassWord$, Keylocation&, 1)) ELSEIF Encry% = 0 THEN AltAsc% = ASC(InCharByte$) + ASC(MID$(PassWord$, Keylocation&, 1)) END IF Keylocation& = Keylocation& + 1 IF Encry% = 1 THEN IF AltAsc% < 1 THEN AltAsc% = 223 + AltAsc% '254 ELSEIF Encry% = 0 THEN IF AltAsc% > 254 THEN AltAsc% = AltAsc% - 223 '254 END IF IF Keylocation& > LenOfKey% THEN Keylocation& = 1 PlaceMe$ = PlaceMe$ + CHR$(AltAsc%) NEXT PRINT #2, PlaceMe$ PlaceMe$ = "" LOOP UNTIL EOF(1) CLOSE #1: CLOSE #2 KILL FileName$ NAME TempFile$ AS FileName$ end sub