` (c)2005 Robert J. Saunders
` just in case it happens to be absolutely brilliant
` and warranting several million dollars.
sync on
sync rate 0
set display mode 800,600,32
set text size 12
color backdrop 0
autocam off
randomize timer()
set image colorkey 0,0,0
set text font "arial"
sync
sync
 
global source$
global output$
global timer$
 
red as integer
bytlen as integer
 
get_a_file:
 
cls
dir
print "enter a file name in this directory to encrypt"
sync
input source$
 
if file exist(source$)=0 then goto get_a_file
 
cls
set text size 70
center text 400,200,"ENCRYPTING!"
sync
 wait 500
 
for t=1 to len(source$)
 if mid$(source$,t)="." then exit
next t
 
timer$=str$(timer()/13337)
 
output$=timer$+left$(source$,t-1)+".enc"
 
open to write 1,output$
 
dim key(33)
restore encryptionkeydata
a=rnd(2)
keykey=a
for t=0 to a
 for u=1 to 33
  read b
  key(u)=b
 next u
next t
 
dim non(7)
restore nonsensedatakey
nonkey=rnd(9)
for t=0 to nonkey
 for u=1 to 7
  read b
  non(u)=b
 next u
next t
 
write byte 1,rnd(9)+1
write byte 1,keykey
write byte 1,rnd(9)+1
write byte 1,nonkey
 
 
count=0
noncount=0
nonstep=1
bytlen=0
 
open to read 2,source$
repeat
 read byte 2,red
 inc bytlen
until file end(2)=1
close file 2
 
write word 1,rnd(65535)
write long 1,bytlen
write word 1,rnd(65535)
 
open to read 2,source$
 
repeat
 
inc noncount
if noncount=non(nonstep)
 write byte 1,rnd(255)
 noncount=0
 inc nonstep
  if nonstep>7 then nonstep=1
endif
 
inc count
if count=34 then count=1
 
read byte 2,red
red=red*key(count)
 
write word 1,red
 
until file end(2)=1
 
close file 1
 
close file 2
 
to_decrypt()
 
end
 
function to_decrypt()
 
cls
set text size 100
center text 400,190,"DECRYPTING!"
sync
 wait 500
 
for t=0 to 33
 key(t)=0
next t
for t=0 to 7
 non(t)=0
next t
 
open to read 3,output$
 
n$="D"+timer$+source$
 
read byte 3,a
read byte 3,keykey
read byte 3,a
read byte 3,nonkey
 
read word 3,a
read long 3,bytlen
read word 3,a
 
restore encryptionkeydata
for t=0 to keykey
 for u=1 to 33
  read b
  key(u)=b
 next u
next t
 
restore nonsensedatakey
for t=0 to nonkey
 for u=1 to 7
  read b
  non(u)=b
 next u
next t
 
open to write 4,n$
 
count=0
noncount=0
nonstep=1
 
repeat
 
inc count
if count=34 then count=1
 
inc noncount
if noncount=non(nonstep)
 read byte 3,a
 noncount=0
 inc nonstep
  if nonstep>7 then nonstep=1
endif
 
read word 3,red
red=red/key(count)
 
write byte 4,red
dec bytlen
 
until file end(3)=1 or bytlen=0
 
close file 3
 
close file 4
 
 
endfunction
 
encryptionkeydata:
data 119,43,166,101,175,135,154,181,202,14,213,130,5,128,211,58,185,103,11,106,28,134,198,40,24,73,50,42,182,172,51,30,88
data 89,10,61,144,124,218,104,147,176,77,123,213,70,31,157,193,201,41,107,167,5,137,26,179,211,75,93,39,43,215,152,196,195
data 91,38,218,167,54,66,130,153,186,220,202,42,22,158,206,165,169,14,30,172,96,145,163,190,85,7,225,115,110,9,56,5,53
data 84,207,160,202,150,131,36,89,67,191,15,164,25,74,86,200,115,58,105,189,95,185,70,6,119,27,109,54,132,203,21,121,81
data 65,132,198,178,147,224,123,189,64,114,122,213,117,56,166,188,6,205,99,13,140,207,157,173,120,5,185,136,196,113,14,42,84
data 191,204,165,184,213,107,119,88,201,53,73,27,97,37,33,157,215,68,70,14,111,187,155,170,134,8,110,121,18,13,105,21,56
data 94,38,66,132,220,175,59,69,111,169,119,163,50,67,170,42,180,22,216,124,147,71,182,29,79,99,96,75,51,17,199,221,200
data 141,196,162,181,125,163,208,100,91,56,109,101,136,47,53,148,35,131,20,201,42,129,150,202,28,90,15,172,94,225,120,58,89
data 206,27,156,29,32,134,143,52,109,125,94,123,193,58,114,79,83,92,5,168,177,82,73,22,31,184,62,24,129,41,63,128,216
data 207,180,191,157,149,102,61,22,33,166,130,147,156,145,64,172,200,113,54,117,106,134,175,211,13,32,24,84,18,223,26,171,35
 
nonsensedatakey:
data 3,4,5,6,7,8,9
data 9,8,7,6,5,4,3
data 5,4,6,7,3,8,9
data 9,7,5,3,4,6,8
data 4,6,8,3,5,7,9
data 3,6,4,7,5,8,9
data 9,6,8,5,7,4,3
data 3,7,5,8,9,6,4
data 7,9,3,4,6,5,8
data 8,6,9,4,3,7,5