FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour HB_Crypt() is not compatible with Latin1
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
HB_Crypt() is not compatible with Latin1
Posted: Sun Sep 06, 2020 02:50 PM

Dear All,

I use MariaDB and I got a problem with HB_Crypt( cPass, cKey ) and store in column (Latin1). When I use HB_Decrypt( oRs:cEncPass, cKey ), it returns incorrect.

What kind of Charactor does support HB_Crypt() or How do I store HB_Crypt and HB_Decrypt() back correctly in MariaDB column.

Thanks in advance for any help or idea.

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: HB_Crypt() is not compatible with Latin1
Posted: Mon Sep 07, 2020 11:52 AM
Works with any language.

Try this test:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oCn, oRs, cSql, aData
   local cKey  := "abcdefgh"

   aData := { { "English", "English" }, { "Thai", "ไทย" }, { "Telugu", "తెలుగు" }, {"Hindi", "हिंदी" }  }
   oCn   := FW_DemoDb( 6 )

   oCn:DropTable( "testcrypt" )

TEXT INTO cSql
CREATE TABLE `testcrypt` (
  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `name` varchar(20),
  `pass` mediumblob
 )
ENDTEXT

   oCn:Execute( cSql )
   oCn:lShowErrors := .t.
   ? oCn:Insert( "testcrypt", "name,pass", { ;
      { aData[ 1, 1 ], HB_Crypt( aData[ 1, 2 ], cKey ) }, ;
      { aData[ 2, 1 ], HB_Crypt( aData[ 2, 2 ], cKey ) }, ;
      { aData[ 3, 1 ], HB_Crypt( aData[ 3, 2 ], cKey ) }, ;
      { aData[ 4, 1 ], HB_Crypt( aData[ 4, 2 ], cKey ) }  ;
      } )



   oRs   := oCn:RowSet( "testcrypt" )
   XBROWSER oRs COLUMNS "id", "name", { || HB_DeCrypt( oRs:pass, cKey ) }

   oCn:Close()

return nil


Regards



G. N. Rao.

Hyderabad, India
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: HB_Crypt() is not compatible with Latin1
Posted: Sat Sep 12, 2020 11:18 AM
Dear Master,

This column type (MEDIUMBLOB) is working properly. Thank you so much.
nageswaragunupudi wrote:Works with any language.

Try this test:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oCn, oRs, cSql, aData
   local cKey  := "abcdefgh"

   aData := { { "English", "English" }, { "Thai", "ไทย" }, { "Telugu", "తెలుగు" }, {"Hindi", "हिंदी" }  }
   oCn   := FW_DemoDb( 6 )

   oCn:DropTable( "testcrypt" )

TEXT INTO cSql
CREATE TABLE `testcrypt` (
  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `name` varchar(20),
  `pass` mediumblob
 )
ENDTEXT

   oCn:Execute( cSql )
   oCn:lShowErrors := .t.
   ? oCn:Insert( "testcrypt", "name,pass", { ;
      { aData[ 1, 1 ], HB_Crypt( aData[ 1, 2 ], cKey ) }, ;
      { aData[ 2, 1 ], HB_Crypt( aData[ 2, 2 ], cKey ) }, ;
      { aData[ 3, 1 ], HB_Crypt( aData[ 3, 2 ], cKey ) }, ;
      { aData[ 4, 1 ], HB_Crypt( aData[ 4, 2 ], cKey ) }  ;
      } )



   oRs   := oCn:RowSet( "testcrypt" )
   XBROWSER oRs COLUMNS "id", "name", { || HB_DeCrypt( oRs:pass, cKey ) }

   oCn:Close()

return nil


Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)

Continue the discussion