This is a section from my DarkBASIC Network IDE, but I would like to know if people found this code useful.
`====================================================================
`DarkBASIC Network IDE
`This file is where we will have all the parts of encryption for the program.
`What we still need to do is to make a section for the file that will encrypt
`a file to memory so that we can work with it rather than making unencrypted files
`all the time.
`Team Members
`1tg46
`Thanatos
`Cellbloc Studios
`====================================================================
function Decryptfile(directory as string, Filename as string)
local filechars as integer
local filenamechars as string
set dir directory
seed=123456789
open to read 1,filename
randomize seed
filechars=len(filename)
filenamechars=left$(filename,filechars-4)
open to write 2,filenamechars
c=file size (filename)
for i=1 to c
read byte 1,d
d=d-rnd(256)
if d<0
d=d+256
endif
write byte 2,d
next i
close file 1
close file 2
delete file filename
set dir ".."
endfunction
function Encryptfile(directory as string, Filename as string)
set dir directory
seed=123456789
open to read 1,filename
randomize seed
open to write 2,filename+".dat"
a=file size(filename)
for i=1 to a
read byte 1,b
b=b+rnd(256)
if b>256
b=b-256
endif
write byte 2,b
next i
close file 1
close file 2
delete file filename
set dir ".."
endfunction
Function Decrypttomemory(directory as string, filename as string, memblock as integer)
set dir directory
seed=123456789
open to read 1,filename
randomize seed
c=file size (filename)
make memblock memblock,c
for i=1 to c
read byte 1,d
d=d-rnd(256)
if d<0
d=d+256
endif
write memblock byte memblock,i,d
next i
close file 1
set dir ".."
endfunction
I am still not sure if Decryptfiletomemory function works or not, havn't tried it.
I am still looking to add compression to this code but I do not know how to do that.

Join the group