Fool proof encryption system by 1tg463rd Nov 2004 20:46
|
---|
Summary 2 good functions for encrypting and decrypting files Description 2 good functions for encrypting and decrypting files Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com 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 |