Page 1 of 1

Encode & Decode functions

Posted: Sat May 30, 2020 4:44 pm
by salamandra
Hi to all,
Anybody knows if Encode & Decode functions are compatible with (or were ported to) UNICODE ?

Best regards,


[]´s Salamandra

Re: Encode & Decode functions

Posted: Sun May 31, 2020 10:54 pm
by salamandra
Hi to all,
Well, Clipper and Harbour functions like Crypt(), HB_Crypt(), HB_Decrypt(), ENCODE <file> and DECODE <file> does not work properly with UNICODE.
I need to protect a single (and small, just 01 record) DBF file with sensitive data in a network environment.
I just need to open this file, pick up the content of a few data fields and close it imediately.
Any ideia about how to do ?

Tia,

[]´s Salamandra.

Re: Encode & Decode functions

Posted: Mon Jun 01, 2020 12:08 am
by AUGE_OHR
hi,

will you use that DBF with different Environment ?
it it for password ?

for Password i do not Crypt it , i store HASH Value.
as i know ANSI and UNICODE work > CHR(128) so if limited i guess it will work in different Environment

Re: Encode & Decode functions

Posted: Mon Jun 01, 2020 12:33 pm
by mustafa
Hola amigo Salamandra
Haber si te puede servir ? este Sample

Está implementado con la librería "Encripta.prg"
http://www.hmgforum.com/viewtopic.php?f ... afa#p45649
http://www.hmgforum.com/viewtopic.php?f ... ted#p32683

SQLITE
http://www.hmgforum.com/viewtopic.php?f ... ted#p59878

Saludos
Mustafa

Re: Encode & Decode functions

Posted: Mon Jun 01, 2020 8:40 pm
by salamandra
Hi @AUGE_OHR,
AUGE_OHR wrote: Mon Jun 01, 2020 12:08 am hi,

will you use that DBF with different Environment ?
it it for password ?

for Password i do not Crypt it , i store HASH Value.
as i know ANSI and UNICODE work > CHR(128) so if limited i guess it will work in different Environment
No, it is not for use with passwords storage.
I have some problems with illegal copies of an ERP system (developed by me).
I want avoid piracy using a DBF file with some crypted fields (Ex. licensed user, serial number, etc.).
I have tried unsuccesfully al known functions of cryptography, that works fine in ANSI mode but does not work at all in UNICODE mode.
I don´t want to use a DBF file with crypted header, but a DBF file with crypted fields.
By the way, how do you get the password hash? have any working example of how i could to do this? I am highly interested...

Best Regards,


[]´s Salamandra - Brazil

Re: Encode & Decode functions

Posted: Mon Jun 01, 2020 8:42 pm
by salamandra
Hola @mustafa,
mustafa wrote: Mon Jun 01, 2020 12:33 pm Hola amigo Salamandra
Haber si te puede servir ? este Sample

Está implementado con la librería "Encripta.prg"
http://www.hmgforum.com/viewtopic.php?f ... afa#p45649
http://www.hmgforum.com/viewtopic.php?f ... ted#p32683

SQLITE
http://www.hmgforum.com/viewtopic.php?f ... ted#p59878

Saludos
Mustafa
Muchas gracias por tu ajuda.
Voy a probar con esta sugerencia y despues te comento si funcionó.



[]´Salamandra - Brasil

Re: Encode & Decode functions

Posted: Mon Jun 01, 2020 11:47 pm
by AUGE_OHR
salamandra wrote: Mon Jun 01, 2020 8:40 pm By the way, how do you get the password hash? have any working example of how i could to do this? I am highly interested...
hi,

sorry, Char2Hash() is a Xbase++ Function using SHA 1 Algorithms

i found these HASH Function in \Harbour\include\hbcompat.ch

Code: Select all

   /* Hash item functions */
   #xtranslate hb_Hash( [<x,...>] )            => Hash( <x> )
   #xtranslate hb_HHasKey( [<x,...>] )         => HHasKey( <x> )
   #xtranslate hb_HPos( [<x,...>] )            => HGetPos( <x> )
   #xtranslate hb_HGet( [<x,...>] )            => HGet( <x> )
   #xtranslate hb_HSet( [<x,...>] )            => HSet( <x> )
   #xtranslate hb_HDel( [<x,...>] )            => HDel( <x> )
   #xtranslate hb_HKeyAt( [<x,...>] )          => HGetKeyAt( <x> )
   #xtranslate hb_HValueAt( [<x,...>] )        => HGetValueAt( <x> )
   #xtranslate hb_HValueAt( [<x,...>] )        => HSetValueAt( <x> )
   #xtranslate hb_HPairAt( [<x,...>] )         => HGetPairAt( <x> )
   #xtranslate hb_HDelAt( [<x,...>] )          => HDelAt( <x> )
   #xtranslate hb_HKeys( [<x,...>] )           => HGetKeys( <x> )
   #xtranslate hb_HValues( [<x,...>] )         => HGetValues( <x> )
   #xtranslate hb_HFill( [<x,...>] )           => HFill( <x> )
   #xtranslate hb_HClone( [<x,...>] )          => HClone( <x> )
   #xtranslate hb_HCopy( [<x,...>] )           => HCopy( <x> )
   #xtranslate hb_HMerge( [<x,...>] )          => HMerge( <x> )
   #xtranslate hb_HEval( [<x,...>] )           => HEval( <x> )
   #xtranslate hb_HScan( [<x,...>] )           => HScan( <x> )
   #xtranslate hb_HCaseMatch( [<x,...>] )      => HGetCaseMatch( <x> )
   #xtranslate hb_HAutoAdd( [<x,...>] )        => HGetAutoAdd( <x> )
   #xtranslate hb_HAllocate( [<x,...>] )       => HAllocate( <x> )
   #xtranslate hb_HDefault( [<x,...>] )        => HDefault( <x> )
   #if defined( HB_LEGACY_LEVEL5 )
   #xtranslate hb_HSetCaseMatch( [<x,...>] )   => HSetCaseMatch( <x> )
   #xtranslate hb_HSetAutoAdd( [<x,...>] )     => HSetAutoAdd( <x> )
   #endif  
no Idea how they work

---

License Problem : we all know the Problem ...

as i found out under harbour you can make Variable "invisibible" in EXE using
http://www.hmgforum.com/viewtopic.php?f=5&t=6448

Code: Select all

 #pragma TEXTHIDDEN(1) 
    PUBLIC  cPassword := "Q65h3l8j41B"        
 #pragma TEXTHIDDEN(0) 

Re: Encode & Decode functions

Posted: Tue Jun 02, 2020 1:06 am
by salamandra
Hi @AUGE_OHR,
sorry, Char2Hash() is a Xbase++ Function using SHA 1 Algorithms
No problem, don´t worry, it is not so important.

i found these HASH Function in \Harbour\include\hbcompat.ch

Code: Select all

/* Hash item functions */
#xtranslate hb_Hash( [<x,...>] ) => Hash( <x> )
#xtranslate hb_HHasKey( [<x,...>] ) => HHasKey( <x> )
#xtranslate hb_HPos( [<x,...>] ) => HGetPos( <x> )
#xtranslate hb_HGet( [<x,...>] ) => HGet( <x> )
#xtranslate hb_HSet( [<x,...>] ) => HSet( <x> )
#xtranslate hb_HDel( [<x,...>] ) => HDel( <x> )
#xtranslate hb_HKeyAt( [<x,...>] ) => HGetKeyAt( <x> )
#xtranslate hb_HValueAt( [<x,...>] ) => HGetValueAt( <x> )
#xtranslate hb_HValueAt( [<x,...>] ) => HSetValueAt( <x> )
.....

#xtranslate hb_HSetCaseMatch( [<x,...>] ) => HSetCaseMatch( <x> )
#xtranslate hb_HSetAutoAdd( [<x,...>] ) => HSetAutoAdd( <x> )
#endif

no Idea how they work
HB_Hash() returns a hash table. I have not tested yet. (but I will)

Code: Select all

#pragma TEXTHIDDEN(1)
PUBLIC cPassword := "Q65h3l8j41B"
#pragma TEXTHIDDEN(0)
Yes, I use this but I need to hide more than a user name or a user password.
I am trying to build a fully new Crypt() function thats be able to work fine with UNICODE (and ANSI of course) to encrypt just certain database fields and not the whole DBF table.

I´ll keep working on it and searching...


Best regards,


Salamandra - Brazil

Re: Encode & Decode functions

Posted: Tue Jun 02, 2020 3:59 am
by AUGE_OHR
hi,

i think you can test if working under UNICODE Environment
than you need some UNICODE Function to convert to ANSI before crypt/decrypt

when read at "HARBOUR string functions that support ANSI and UNICODE character set"
that Hb_MemoRead() work with both ...hm

i guess we talk about String so it might work with

Code: Select all

IF lUniCode
  cText := deCrpyt( Hb_MemoRead(Field->MyText) )
ELSE
  cText := deCrpyt( Field->MyText) 
ENDIF
instead of Hb_MemoRead() sou can try HB_UTF8TOSTR() which need same Codepage on Crypt / deCrypt