FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour New file format
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
New file format
Posted: Sun Nov 20, 2022 11:33 AM

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

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: New file format
Posted: Sun Nov 20, 2022 04:45 PM
Silvio,
maybe this helps.

Best regards,

Otto
Code (fw): Select all Collapse
// 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

//----------------------------------------------------------------------------//
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: New file format
Posted: Sun Nov 20, 2022 08:00 PM

Perhaps can be a good idea!!

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: New file format
Posted: Tue Nov 22, 2022 09:00 AM
Otto wrote:Silvio,
maybe this helps.

Best regards,

Otto
Code (fw): Select all Collapse
// 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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: New file format
Posted: Tue Nov 22, 2022 03:08 PM
Do not provide the file name as the first paramter. Keep it NIL.
Then the method returns CsvText.
Code (fw): Select all Collapse
cCsvText := oBrw:ToCSV( NIL, , .f., , , "," ) 
cCsvText := ENCRYPT( cCsvText, cKey )
HB_MEMOWRIT( cFile, cCsvText )
No need to modify the classes of xbrowse.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: New file format
Posted: Tue Nov 22, 2022 03:08 PM
Do not provide the file name as the first paramter. Keep it NIL.
Then the method returns CsvText.
Code (fw): Select all Collapse
cCsvText := oBrw:ToCSV( NIL, , .f., , , "," ) 
cCsvText := ENCRYPT( cCsvText, cKey )
HB_MEMOWRIT( cFile, cCsvText )
No need to modify the classes of xbrowse.
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: New file format
Posted: Tue Nov 22, 2022 05:41 PM
nageswaragunupudi wrote:Do not provide the file name as the first paramter. Keep it NIL.
Then the method returns CsvText.
Code (fw): Select all Collapse
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?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New file format
Posted: Tue Nov 22, 2022 09:14 PM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: New file format
Posted: Tue Nov 22, 2022 10:18 PM

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, sextuplets, sevenths, eights, novines and tens.

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New file format
Posted: Tue Nov 22, 2022 10:30 PM
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 :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: New file format
Posted: Wed Nov 23, 2022 09:27 AM
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 :



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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion