Basically, it goes through a file, and encodes it. You can then decode the file.
`Write an encoded string
function write_encode_string(num, string$)
`This will go through a string, and write the float value of
`the string. The float value is basically an encrypted value.
for i=1 to len(string$)
write float num, val(mid$(string$,i))
next i
endfunction
`Encode a file
function encodeFile(file$, num, num2)
`Open the file for reading. Num is the id of the file
open to read file$,num
`We create a temporary file here, num2 is the id of it.
open to write "C:WindowsTempTemp.00.tmp",num2
`I write a float at the beginning for verification purposes. This value may be changed, as long as the changed value is also checked.
write float num2,47.93
`While the file has not come to an end, read from it
while file end(num)=0
read string num,string$
`We write the encoded version of the string just read, to the temporary file
write_encode_string(num2,string$)
endwhile
`Repeat the process once more, because when dbp says the file has ended, it means the file will end after the next read call.
read string num,string$
write_encode_string(num2,string$)
`Close both files
close file num
close file num2
`Delete the file that was read from
delete file file$
`Move the temporary file (also renaming it) to the position and name of the file that was read from
move file "C:WindowsTempTemp.00.tmp",file$
endfunction
`Decode a file
function decodeFile(file$, num, num2)
`Open the file for reading, see above explanation.
`This is basically the same as the above, but in reverse.
open to read file$,num
open to write "C:WindowsTempTemp.01.tmp",num2
read float num,float#
if float#=47.93
while file end(num)=0
read float num,float#
write byte num2,int(float#)
endwhile
read float num,float#
write byte num2,int(float#)
else
`Handle non-encoded format error here.
endif
close file num
close file num2
delete file file$
move file "C:WindowsTempTemp.01.tmp",file$
endfunction
These have not been tested, but have been based off of something I did make, very, very similiar to this. If they dont work, I can make them work.
-db
[edit]
I editted the code to make it a bit easier to understand.
[/edit]