i tried to make it that way before. the program reads from a file input.txt and encrypt it all. but for some reason the program shut down if the input file was to long! i did never figure out why... maybe you can?
Rem Project: encryption
Rem Created: 2004-06-08 20:54:49
Rem ***** Main Source File *****
rem setup
set display mode 640, 480, 16
sync off
REM ------ KEY ------
rem read the key
open to read 1, "key.txt"
read string 1, key$
rem make all lower case
key$ = lower$(key$)
rem check length
keylength = len(key$)
if keylength <> 29
print "Key is to short! Key should contain 29 signs. Aborting operation."
print "Length of key: ";keylength
suspend for key
end
endif
rem make the kay array
dim keyarray$(28)
rem write key into array
for x=1 to 29
keychar$ = mid$(key$, x)
keyarray$(x-1) = keychar$
next x
rem print key
cls
rem temp variable, captial A = 65
ascii = 64
rem print key
print "This is the key: "
for x=0 to 25
inc ascii
print chr$(ascii);" = ";keyarray$(x)
next x
print chr$(197);" = ";keyarray$(26)
print chr$(196);" = ";keyarray$(27)
print chr$(214);" = ";keyarray$(28)
rem print done message
print " "
print "Key contains ";keylength;" characters."
print " "
print "Key loaded... Press any key to continue"
suspend for key
REM ------ KEY END ------
REM ------ MESSAGE ------
cls
set cursor 150,50
print "Loading message: "
open to read 2, "input.txt"
read string 2, clear$
clear$ = lower$(clear$)
filelength = len(clear$)
rem print done mesage
set cursor 150,100
print clear$
set cursor 150,150
print "Length of message: ";filelength
set cursor 150,200
print "Message loaded... Press any key to continue"
suspend for key
cls
REM ------ MESSAGE ------
rem this is where the finished product will go
crypt$ = ""
rem prepare to translate
set cursor 150,100
print "Variables created, ready to translate... Press any key to continue."
suspend for key
cls
REM ------ ENCRYPTION ------
for x=0 to filelength
char$ = mid$(clear$, x)
set cursor 150,50
print "char$: ";char$
rem set cursor back to normal
set cursor 0,0
rem the ascii variable, 97 = lower case a... ascii is increased so 96 have no effect
ascii = 96
rem this is temp space
y$ = "6"
for translate=-1 to 31
inc ascii
if asc(char$) = ascii then y$ = keyarray$(translate+1)
rem åäö
rem 229=å 228=ä 246=ö
rem keyarray 26=å 27=ä 28=ö
if asc(char$) = 229 then y$ = keyarray$(26)
if asc(char$) = 228 then y$ = keyarray$(27)
if asc(char$) = 246 then y$ = keyarray$(28)
next translate
rem if nothing matched, dont encrypt character
if y$ = "6" then y$ = char$
set cursor 150,100
print "y$: ";y$
crypt$ = crypt$ + y$
set cursor 150,150
print "crypt$: ";crypt$
set cursor 150,200
print "Press space to encrypt next character or Escpape to encrypt entire message."
suspend for key
cls
next x
REM ------ ENCRYPTION END ------
open to write 3, "encrypted.txt"
write string 3, crypt$
rem print done message
cls
set cursor 150,50
print "Encryption done! Press any key to quit."
set cursor 150,100
print "Encrypted message: "
set cursor 150,150
print crypt$
sync
suspend for key
that way everything would be so much easier. please solve this one as it did reeeally puzzle me
thanks anyway
cheers and goodnight (night for me at least
)
Dreaming of creating a highly advanced AI mind