TESTER INFORMATION

Hello, my name is Karl Albrecht and I own a small company 
called K & T.  K & T is a small consulting firm that 
specializes in teaching people to program in basic.  I'd like 
to thank you for helping test out my software that is for Free 
Distribution.

KTEncrypt started off life as an experiment on simplified 
string encryption.  Please note that I call it string, rather 
than file, encryption.  KTEncrypt is an offshoot of a file 
encryption technique I developed a while back.  The earlier 
version used a simple XOR method with a complex encrypting 
key,  The problem inherent with XOR method is it will return a 
new character of any value from 0 to 255.  This is fine if you 
are writing to a file in binary mode but most people are not 
comfortable using binary file interaction.  Most people are 
familiar with standard text files so I wanted an encryption 
technique to work with that.  The problem lie in that there are 
several characters that you cannot save to a text file and get 
the same string read back.  They are

     0  -  Creates a null character

     10 -  Creates a line feed

     13 -  Creates a carriage return causing a new record.

     26 -  Causes an End or File

They idea is simple, these ANSI codes must be detected and 
filtered out.  My original experiments seemed way to slow using 
XOR so I tried an alternative which eventually became KTEncrypt
version 1.1.  After some thought I came up with a new way to 
use XOR and redesigned KTEncrypt from the ground up which is 
the version you are looking at now.  KTEncrypt version 2.0 is 
much faster than the original version and much more reliable 
and harder to crack.  Here is an explanation of it:



KTEncrypt
---------

    KTEncrypt (password, strng, force%)

      password - A string composed of any ANSI character code
                 (0 to 255).  Must be at least 1 character long
                 and up to 255 characters in total length.  This
                 argument is case sensitive.

      strng    - A string composed of any ANSI character codes.
                 This is the string that you want to encrypt or
                 decrypt.  Maximum length appears to be around
                 30,000 characters in length.

      force%   - An integer flag

                 0 - AUTO MODE, the function will automatically 
                     detect if the strng is encrypted and take
                     appropriate action.  If string is being
                     decrypted then password will be verified.

             NOT 0 - FORCE MODE, will encrypt the string 
                     regardless if it is already encrypted.  
                     This is used to encrypt a string multiple
                     times with different passwords for stronger
                     security. Two people each can have a 
                     password to a file so they can only read 
                     it together.


ERRORS - If an error occurs KTEncrypt aborts and returns a null 
value.  Possible errors are as follows

       NO PASSWORD
       PASSWORD TOO LONG
       INVALID PASSWORD
       STRING TO LONG (SOMEWHERE > 30,000)
       

EXPLANATION

First KTEncrypt will check if your string is encrypted or not 
(this is skipped if force% is not 0).  It does this by adding a 
tag after a file is encrypted.  The tag is CHR$(1)+"KT"+CHR$(1) 
and is added to the beginning and ending of the strng.  If 
these are not present the file was not encrypted.

If the file was encrypted we must remove the CHR$(1) flags 
placed in the file.  these flags are used to indicate where the 
'bad' codes were.  The character immediately after the CHR$(1) 
is the bad character with one added to it's code.  So we loop 
through looking for CHR$(1) then eliminate it and then subtract 
one from the following characters ANSI code.  Now we are ready 
to decrypt the string.  

If the file was not encrypted we skip this and prepare for 
encrypting.

Next for either case we need to develop the password.  the 
problem with XOR is it can be dumb.  Passwords can be perceived 
as the same. 'a' is the same as 'aa' or aaa...' as well as 'as' 
is the same as 'asas' or 'asasas...'.  Because of this we add 
characters to the password.  This also helps make short 
passwords longer.

Next if we are encrypting we add a small string to the 
beginning of the main string which is based on your password 
which is later used upon decrypting to validate passwords.  
Next we loop though and modify the ANSI values using XOR.  This 
is the same whether encrypting or decrypting.

Once complete if we are encrypting we check for and flag 'bad' 
character codes.  Add the encrypted tag and exit.

If decrypting we check if the password is valid and exit.

Fairly simple but if you have questions please ask.



ADDITIONS
---------
Would it be better if there is an error that it be returned by 
the function?  Really, the only error to worry about is invalid 
password because you can check everything before you call the 
function.

I can add a feature that encodes the file length so it can 
check for corruption.  Would this be useful??


Thank you for your help.  Will be waiting to hear from you.
