HB_Crypt() is not compatible with Latin1

HB_Crypt() is not compatible with Latin1

Postby dutch » Sun Sep 06, 2020 2: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 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: HB_Crypt() is not compatible with Latin1

Postby nageswaragunupudi » Mon Sep 07, 2020 11:52 am

Works with any language.

Try this test:
Code: Select all  Expand view
#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
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: HB_Crypt() is not compatible with Latin1

Postby dutch » 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: Select all  Expand view
#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
 


Image
Regards,
Dutch

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 33 guests