Page 1 of 1

New file format

PostPosted: Sun Nov 20, 2022 11:33 am
by Silvio.Falconi
I saved a table in an ascii file with the separator character "," or ";" but I would like to protect this file and create a particular and personalized format that no one could reopen but me with my little program
of course I need the save function and to load the file and once saved

Re: New file format

PostPosted: Sun Nov 20, 2022 4:45 pm
by Otto
Silvio,
maybe this helps.

Best regards,

Otto

Code: Select all  Expand view

// New FiveWin Encrypt() and Decrypt() functions

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local cTest1 := "FiveWin - The CA-Clipper for Windows Library"
   local cTest2 := "FiveWin - The CA-Clipper for Windows Library"

   MsgInfo( cTest1 := Encrypt( cTest1, "User1Key" ) )
   MsgInfo( cTest2 := Encrypt( cTest2, "Another" ) )

   MsgInfo( cTest1 := Decrypt( cTest1, "User1Key" ) )
   MsgInfo( cTest2 := Decrypt( cTest2, "Another" ) )

return nil

//----------------------------------------------------------------------------//


 

Re: New file format

PostPosted: Sun Nov 20, 2022 8:00 pm
by Silvio.Falconi
Perhaps can be a good idea!!

Re: New file format

PostPosted: Tue Nov 22, 2022 9:00 am
by Silvio.Falconi
Otto wrote:Silvio,
maybe this helps.

Best regards,

Otto

Code: Select all  Expand view

// New FiveWin Encrypt() and Decrypt() functions

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local cTest1 := "FiveWin - The CA-Clipper for Windows Library"
   local cTest2 := "FiveWin - The CA-Clipper for Windows Library"

   MsgInfo( cTest1 := Encrypt( cTest1, "User1Key" ) )
   MsgInfo( cTest2 := Encrypt( cTest2, "Another" ) )

   MsgInfo( cTest1 := Decrypt( cTest1, "User1Key" ) )
   MsgInfo( cTest2 := Decrypt( cTest2, "Another" ) )

return nil

//----------------------------------------------------------------------------//


 


Sorry I not understood how make it because I create csv from xbrowse with oBrw:ToCSV( cFile, , .f., , , "," ) and cFile is the name of the file

Re: New file format

PostPosted: Tue Nov 22, 2022 3:08 pm
by nageswaragunupudi
Do not provide the file name as the first paramter. Keep it NIL.
Then the method returns CsvText.
Code: Select all  Expand view

cCsvText := oBrw:ToCSV( NIL, , .f., , , "," )
cCsvText := ENCRYPT( cCsvText, cKey )
HB_MEMOWRIT( cFile, cCsvText )
 


No need to modify the classes of xbrowse.

Re: New file format

PostPosted: Tue Nov 22, 2022 3:08 pm
by nageswaragunupudi
Do not provide the file name as the first paramter. Keep it NIL.
Then the method returns CsvText.
Code: Select all  Expand view

cCsvText := oBrw:ToCSV( NIL, , .f., , , "," )
cCsvText := ENCRYPT( cCsvText, cKey )
HB_MEMOWRIT( cFile, cCsvText )
 


No need to modify the classes of xbrowse.

Re: New file format

PostPosted: Tue Nov 22, 2022 5:41 pm
by Silvio.Falconi
nageswaragunupudi wrote:Do not provide the file name as the first paramter. Keep it NIL.
Then the method returns CsvText.
Code: Select all  Expand view

cCsvText := oBrw:ToCSV( NIL, , .f., , , "," )
cCsvText := ENCRYPT( cCsvText, cKey )
HB_MEMOWRIT( cFile, cCsvText )
 


No need to modify the classes of xbrowse.


thanks...why I 'm seeing two answers?

Re: New file format

PostPosted: Tue Nov 22, 2022 9:14 pm
by Antonio Linares
Dear Silvio,

You should use Harbour's HB_BLOWFISHENCRYPT() if you want the max security

FWH Encrypt() and Decrypt() are quite simple, enough for many people, but an expert could break it

Re: New file format

PostPosted: Tue Nov 22, 2022 10:18 pm
by Silvio.Falconi
I Wish create a new file format but i not knor how make It
to start I can settle for the encript /decriot functions, but I wanted to save all the information I need in a single file: in reality they are matrices for creating betting systems for the lotto scheme title, rows, columns, guarantee, points and then the whole scheme that could have up to a maximum of ten columns but infinite rows depending on the numbers that are played if they are placed in doubles or triplets or quadruplets, five, _, sevenths, eights, novines and tens.

Re: New file format

PostPosted: Tue Nov 22, 2022 10:30 pm
by Antonio Linares
Dear Silvio,

Save the info into a Harbour hash, then generate a JSON file from it, then encrypt it to disk

Then you can read it back, decrypt it and recover the JSON and then convert it into a Harbour hash again

Thats what I would do :-)

Re: New file format

PostPosted: Wed Nov 23, 2022 9:27 am
by Silvio.Falconi
for Now
File ascii cripted
name of file
NXX_GXEX_LXX.TBL

sample : N08_G2E2_L03.TBL -> 8 numbers, Guarantee 2, Points 2 , scheme in triplets

the problem is when I select the numbers sample :

Image

the procedure should search for a 9-digit scheme and list the schemes found
on a xbrowse two colomuns if the procedure found that schemes it must write
"should convert the abbreviation N08_G2E2_L03 to
scheme | columns
"guarantee 2 numbers with 8 numbers" | 3
and it's not easy