Encrypt and Decrypt errors

Encrypt and Decrypt errors

Postby Silvio.Falconi » Tue Sep 11, 2018 8:15 am

On a ftp procedure I use this configuration to upload and download a file from fwh
Code: Select all  Expand view

   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


Image



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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Encrypt and Decrypt errors

Postby carlos vargas » Tue Sep 11, 2018 9: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: Select all  Expand view

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

Code: Select all  Expand view

#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)
User avatar
carlos vargas
 
Posts: 1719
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Encrypt and Decrypt errors

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Encrypt and Decrypt errors

Postby Silvio.Falconi » Wed Sep 12, 2018 10:30 am

I tried to Use your function but it seem not run ok

Image

Look the get top at right
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Encrypt and Decrypt errors

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Encrypt and Decrypt errors

Postby carlos vargas » Wed Sep 12, 2018 5:26 pm

OK.
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1719
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Encrypt and Decrypt errors

Postby fraxzi » Wed Sep 19, 2018 2: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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Encrypt and Decrypt errors

Postby fraxzi » Wed Sep 19, 2018 2: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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Encrypt and Decrypt errors

Postby carlos vargas » Wed Sep 19, 2018 5:22 pm

please include
Code: Select all  Expand view

#include "hbcompat.ch"
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1719
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Encrypt and Decrypt errors

Postby fraxzi » Thu Sep 20, 2018 7:03 am

carlos vargas wrote:please include
Code: Select all  Expand view

#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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests

cron