On Mon, 26 Jan 2009, Sérgio Kondo wrote:

Hi,

> Is possible to compact .hrb files or encrypt string in .hrb files?
> My interest is hide password string in .hrb files, if I put password
> string in this file.

You can make anything what you want with .hrb files body. You only
have to decode it before you will call HB_HRBLOAD( <cHrbBody> ), f.e.
you can use this function to compress and encrypt .hrb files:

   proc encode_hrb( cKey )
      local cHrbBody, file
      for each file in directory( "*.hrb" )
         cHrbBody := hb_memoread( file[ 1 ] )
         if !empty( cHrbBody )
            cHrbBody := hb_zcompress( cHrbBody )
            cHrbBody := sx_encrypt( cHrbBody, cKey )
            hb_memowrit( file[ 1 ] + "enc", cHrbBody )
         endif
      next
      return

and this one to load such files:

   proc load_hrb( cKey, cFile, /* init function parameters*/ ... )
      local cHrbBody
      cHrbBody := hb_memoread( cFile )
      cHrbBody := sx_decrypt( cHrbBody, cKey )
      cHrbBody := hb_zuncompress( cHrbBody )
      hb_hrbLoad( cHrbBody, ... )
      return

In both functions <cKey> is used as encryption key. It's not strong
encryption but for simple string hiding should be enough.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to