FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Encrypt and Decrypt errors
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Encrypt and Decrypt errors
Posted: Tue Sep 11, 2018 08:15 AM
On a ftp procedure I use this configuration to upload and download a file from fwh
Code (fw): Select all Collapse
   Local cFtp     :=( pad(GetPvProfString("Config","Ftp" ,""   ,::cIniFtp ) , 60 ," " ) )
   Local cFtpDir  :=( pad(GetPvProfString("Config","FtpDir" ,"",::cIniFtp ) , 60 ," " ) )
   Local cUser    :=( pad(GetPvProfString("Config","User" ,""  ,::cIniFtp ) , 60 ," " ) )
   Local cPws     :=( pad(GetPvProfString("Config","Password" ,""  ,::cIniFtp ) , 60 ," " ) )
   Local cUpdFile :=( pad(GetPvProfString("Config","Filename" ,""  ,::cIniFtp ) , 60 ," " ) )
   Local cLocalDir:=( pad(GetPvProfString("Config","Cartella" ,""  ,::cIniFtp ) , 60 ," " ) )


I wish use Encrypt and Decrypt functions

WritePProString("Config","Ftp",Encrypt(cFtp),::cIniFtp)
or
Local cFtp :=Decrypt( pad(GetPvProfString("Config","Ftp" ,"" ,::cIniFtp ) , 60 ," " ) )

When I encrypt fwh run ok and the infodata are save on ini file

but I use decrypt and I wish load the info data I saved it not return the data clear






If I insert a IP for sample 168.200.1.1 instead ftp.xxxx.it

it make error

Any solution please?
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: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Encrypt and Decrypt errors
Posted: Tue Sep 11, 2018 09:32 PM
Silvio, the Encrypt function may be generating non-printable characters which generate this type of problems, the ideal is to complement it with the functions that work with hexadecimal.
Code (fw): Select all Collapse
WritePProString("Config","Ftp",Str2HexCrypt(cFtp),::cIniFtp)
or
Local cFtp :=HexCrypt2Str( pad(GetPvProfString("Config","Ftp" ,"" ,::cIniFtp ) , 60 ," " ) )

Code (fw): Select all Collapse
#define LOGIN_KEY "MySeed2018"

FUNCTION Str2HexCrypt( cString, nSize, cSeed )
   LOCAL cHex := ""

   DEFAULT nSize := Len( cString ), cSeed := LOGIN_KEY

   IF !Empty( cString )
      IF nSize > 0
         cHex := HB_StrToHex( HB_Crypt( PadR( cString, nSize ), cSeed ) )
      ELSE
         cHex := HB_StrToHex( HB_Crypt( cString, cSeed ) )
      ENDIF
   ENDIF

RETURN cHex

/*-------------------------------------------------------------------------------------------------*/

FUNCTION HexCrypt2Str( cStringHex, cSeed )
   LOCAL cStr := ""

   DEFAULT cSeed := LOGIN_KEY

   IF !Empty( cStringHex )
      cStr := HB_Decrypt( HB_HexToStr( cStringHex ), cSeed )
   ENDIF

RETURN cStr
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Encrypt and Decrypt errors
Posted: Wed Sep 12, 2018 10:21 AM

thanks
I saw the functions
you have correct also the encrypt function or there is not problem for the encrypt ?
do you have found aes cript functions )

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: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Encrypt and Decrypt errors
Posted: Wed Sep 12, 2018 10:30 AM
I tried to Use your function but it seem not run ok



Look the get top at right
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: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Encrypt and Decrypt errors
Posted: Wed Sep 12, 2018 10:36 AM

Sorry My mistake run ok
I forget to set LOGIN_KEY

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: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Encrypt and Decrypt errors
Posted: Wed Sep 12, 2018 05:26 PM

OK.

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: Encrypt and Decrypt errors
Posted: Wed Sep 19, 2018 02:39 AM

Hi All,

how to use HB_StrToHex()/HB_HexToStr() in xHarbour ... Any equivalent?

:?:

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: Encrypt and Decrypt errors
Posted: Wed Sep 19, 2018 02:57 AM

I got it...

Str2Hex() and Hex2Str() ...

:)

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Encrypt and Decrypt errors
Posted: Wed Sep 19, 2018 05:22 PM
please include
Code (fw): Select all Collapse
#include "hbcompat.ch"
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: Encrypt and Decrypt errors
Posted: Thu Sep 20, 2018 07:03 AM
carlos vargas wrote:please include
Code (fw): Select all Collapse
#include "hbcompat.ch"



Thanks Carlos!

:-)
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15

Continue the discussion