Hi Cescano, I quickly threw an example together which demonstrates how to obfuscate strings within save files. There is plenty of room for improvement and is by no means "secure" but certainly does the job.
It works by retrieving the Ascii code for each character within the string, then uses bit shifting to modify the data before writing. The process is then reversed to read strings back from the file.
Sorry for the lack of comments, but it should be enough to get you going.
// Obfuscation of strings within save files
// Snippet By: revenant_chaos
FileName$ = "File.txt"
Open To Write 1, FileName$
WriteScrambledString(1, "This String Will Be Written To The File." )
WriteScrambledString(1, "And Here Is A Second String." )
Close File 1
Open To Read 1, FileName$
print ReadScrambledString$(1)
print ReadScrambledString$(1)
Close File 1
wait key
end
Function WriteScrambledString(FileNum as integer, WriteStr$ as string)
StrLen = len(WriteStr$)
for i=1 to StrLen
Write byte FileNum,Scramble( mid$(WriteStr$,i) )
next i
//terminate the string with a zero (null)
write byte FileNum,0
endfunction
Function ReadScrambledString$(FileNum as integer)
ReadStr$ as string
eos as integer
Repeat
Read byte FileNum,Code
if Code > 0
ReadStr$ = ReadStr$ + DeScramble(Code)
else
eos = 1
endif
Until file end(FileNum) or eos = 1
endfunction ReadStr$
Function Scramble(Chr as String)
OutCode = asc( Chr ) << 1
endfunction OutCode
Function DeScramble(Code as integer)
OutChr$ = chr$( Code >> 1 )
endfunction OutChr$