Posts: 1,769
Threads: 410
Joined: Feb 2003
is there a way that qm can ceate a file that is encrypted and write to that file?
think of it as sort of a protected log that is getting written to every so often.
thanks.
Posts: 12,072
Threads: 140
Joined: Dec 2002
What is better:
A. Use Windows "File Encryption" feature
http://msdn.microsoft.com/library/defau ... yption.asp
B. Encrypt log strings using str.ecrypt.
?
Posts: 1,769
Threads: 410
Joined: Feb 2003
well, i'm not sure which would be the best way (system resources wise).
i would have strings printing to this file as much as every 5-10 seconds. would it be better to unencrypt the whole file add the line and then encrypt again or would it be better to "stack" the encrypted lines and decrytp them one at a time?
what are your thoughts?
Posts: 12,072
Threads: 140
Joined: Dec 2002
Function LogEncrypted
;/
function str's [flags] [$logfile]
s.encrypt(9 s "password")
LogFile s flags logfile
Function DecryptLogFile
;/
function $source_file $dest_file
str sf df s
sf.getfile(source_file)
foreach s sf
,if(findc(s ':')<0) s.decrypt(9 s "password")
,df.formata("%s[]" s)
df.setfile(dest_file)
Change "password".
Posts: 1,769
Threads: 410
Joined: Feb 2003
works great thanks!
wondering about changing the logfile size. i changed the below line from 50 to 1000 but it didnt seem to take when i changed the encrypt line.
if(!_logfilesize) _logfilesize=1000*1024
old encrypt
to this
LogFileBig s flags logfile
is there something im missing?
thanks
Posts: 12,072
Threads: 140
Joined: Dec 2002
Is LogFileBig exact copy of LogFile, except 50?
Posts: 1,769
Threads: 410
Joined: Feb 2003
yes.
;/
function ~s [flags] [$logfile] ;;flags: 1 date/time
;Writes s to the end of the log file.
;s - string or number to write.
;logfile - file name. Default: _logfile (global variable, read more in QM help).
;If file size exceeds _logfilesize (global variable, default is 50 KB), removes first half (oldest data).
;EXAMPLES
;LogFile "string"
;int a=10
;LogFile a 1
if(!len(logfile)) logfile=_logfile
File f.Open(logfile "a+")
int i=f.FileLen
if(!_logfilesize) _logfilesize=1000*1024
if(i>_logfilesize)
,f.SetPos(_logfilesize/2)
,f.ReadToStr(_s)
,f.Close
,f.Open(logfile "w")
,i=findc(_s 10)+1
,f.Write(_s+i _s.len-i)
if(flags&1) s-_s.time("%c[]")
f.WriteLine(s)
err+ end ES_FAILED
Posts: 1,769
Threads: 410
Joined: Feb 2003
Posts: 12,072
Threads: 140
Joined: Dec 2002
_logfilesize is changed only if 0. Don't use it.
;/
function ~s [flags] [$logfile] ;;flags: 1 date/time
if(!len(logfile)) logfile=_logfile
File f.Open(logfile "a+")
int i=f.FileLen
int logfilesize=1000*1024
if(i>logfilesize)
,f.SetPos(logfilesize/2)
,f.ReadToStr(_s)
,f.Close
,f.Open(logfile "w")
,i=findc(_s 10)+1
,f.Write(_s+i _s.len-i)
if(flags&1) s-_s.time("%c[]")
f.WriteLine(s)
err+ end ES_FAILED
Posts: 1,769
Threads: 410
Joined: Feb 2003
ahhhh....that's got it!
thanks.