' ' a text file encryption and decryption routine created with Rapid-Q ' 5/28/00 ' Scott aka Sand Dune ' $include "rapidq.inc" declare sub do_it ' the subroutine "do_it" encrypts and decrypts the text dim lin$ as string ' this holds each line of text that we will process dim kar$ as string ' this holds each character in a line dim pass$ as string ' the password is used to scramble each character in the text dim new_kar$ as string ' the new character created when scrambling or unscrambling dim new_line$ as string ' the new line created when scrambling or unscrambling dim mode$ as string ' a flag to determine whether to encrypt (1) or decrypt (0) dim line_len# as integer ' the length of the line to loop through when processing dim line_loop# as integer ' the line counter when looping thru each character in the line dim kar# as integer ' the ascii equivalent of the character being processed dim scram# as integer ' the modulo remainder used when scrambling eggs (or undoing) dim pass_len# as integer ' the length of the password used in the cryptography formula '---------------------------------------------------------------------------------------- ' assign some text and show it, call the encrypt routine, show it, decrypt it, show it ' pass$ = "wrialpliidaqm" ' password containing "william" and "rapidq" every other letter pass_len# = len(pass$) ' the length of the password that was so cleverly designed lin$ = "Scott is called Sand Dune because he lives near the Atlantic Ocean" ' text2encrypt ?lin$ ' show the text before doing anything to it mode$ = "1" ' set the flag for encrypting the data (scramble them eggs) do_it ' call the subroutine to "do it" ?new_line$ ' show the encryption results lin$ = new_line$ ' assign the encrypted line to be decrypted mode$ = "0" ' set the flag for decrypting the data (unscramble) do_it ' call the subroutine to "do it" ?new_line$ ' show the decryption results ' the end ' normal end of program '---------------------------------------------------------------------------------------- ' the little engine that does the work ' sub do_it ' this subroutine encrypts and decrypts text based on "mode$" ' line_len# = len(lin$) ' get the length of the line to do new_line$ = "" ' initialize a new line to create for line_loop# = 1 to line_len# ' loop thru each character in line kar$ = mid$(lin$, line_loop#, 1) ' extract individual character kar# = asc(kar$) ' get ascii value of that character scram# = line_loop# mod pass_len# ' get remainder of pos and pass len if mode$ = "1" then ' if parameter one is a "1" kar# = kar# + asc( mid$(pass$, scram#, 1) ) ' encrypt the character else ' or else it is a "0" and we should kar# = kar# - asc( mid$(pass$, scram#, 1) ) ' decrypt the character end if ' end of 'if parameter is "1" new_kar$ = chr$(kar#) ' assign the new character new_line$ = new_line$ + new_kar$ ' append it to the new output line next ' end of loop thru each character ' end sub '----------------------------------------------------------------------------------------