Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
encrypted file
#1
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.
An old blog on QM coding and automation.

The Macro Hook
#2
What is better:

A. Use Windows "File Encryption" feature http://msdn.microsoft.com/library/defau ... yption.asp

B. Encrypt log strings using str.ecrypt.

?
#3
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?
An old blog on QM coding and automation.

The Macro Hook
#4
Function LogEncrypted
Code:
Copy      Help
;/
function str's [flags] [$logfile]

s.encrypt(9 s "password")
LogFile s flags logfile

Function DecryptLogFile
Code:
Copy      Help
;/
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".
#5
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.

Code:
Copy      Help
if(!_logfilesize) _logfilesize=1000*1024

old encrypt
Code:
Copy      Help
LogFile s flags logfile

to this
Code:
Copy      Help
LogFileBig s flags logfile

is there something im missing?


thanks
An old blog on QM coding and automation.

The Macro Hook
#6
Is LogFileBig exact copy of LogFile, except 50?
#7
yes.

Code:
Copy      Help
;/
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
An old blog on QM coding and automation.

The Macro Hook
#8
removed
An old blog on QM coding and automation.

The Macro Hook
#9
_logfilesize is changed only if 0. Don't use it.

Code:
Copy      Help
;/
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
#10
ahhhh....that's got it!

thanks.
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 1 Guest(s)