Page 1 of 1

Sqlite unrecognized token

Posted: Tue Apr 09, 2019 10:08 pm
by karweru
Hi,

I'm encrypting a string using hb_blowfishEncrypt() before writing it to an sqlite table. Sometimes it generates an unrecognized token error. Is there a way around this?

Kindly assist.

Re: Sqlite unrecognized token

Posted: Wed Apr 10, 2019 11:07 am
by mustafa

Re: Sqlite unrecognized token

Posted: Wed Apr 10, 2019 12:12 pm
by mustafa
Samples

Code: Select all


#include <hmg.ch>

Function Main

*---------------------------------------------------------------------------------------------* 
 #pragma TEXTHIDDEN(1) 
   PUBLIC  cKey   := "Q65h3l8j41B"  // <- Very important not to change Password or Delete !!!                  
 #pragma TEXTHIDDEN(0) 
*---------------------------------------------------------------------------------------------*
   PRIVATE cText  := 'Test of crypto...' 
   PRIVATE cBlow1 := hb_blowfishEncrypt( hb_blowfishKey( cKey ), cText ) 
   PRIVATE cBlow2 := hb_blowfishDecrypt( hb_blowfishKey( cKey ), cBlow1 ) 
   PRIVATE cSix1  := sx_encrypt( cText, cKey ) 
   PRIVATE cSix2  := sx_decrypt( cSix1, cKey ) 
   PRIVATE cXhb1  := hb_crypt( cText, cKey ) 
   PRIVATE cXhb2  := hb_decrypt( cXhb1, cKey ) 
*---------------------------------------------------------------------------------------------*
   
   MsgInfo( cText  , "Text") 
   MsgInfo( cKey   , "Key" ) 

   MsgInfo( cBlow1 , "hb_blowfishEncrypt") 
   MsgInfo( cBlow2 , "hb_blowfishDecrypt" ) 

   MsgInfo( cSix1  , "sx_encrypt") 
   MsgInfo( cSix2  , "sx_decrypt" ) 

   MsgInfo( cXhb1  , "hb_crypt" ) 
   MsgInfo( cXhb2  , "hb_decrypt") 
 
RETURN 

Mustafa

Re: Sqlite unrecognized token

Posted: Wed Apr 10, 2019 5:00 pm
by karweru
Thank you very much Mustafa. I adopted vszakats code you've shown above like below,...works perfectly.

FUNCTION encode(cStr,cPass)
local cBfKey
cBfKey := hb_blowfishKey(cPass)
Return hb_StrToHex(hb_blowfishEncrypt(cBfKey, cStr))

FUNCTION decode(cEncoded,cPass)
local cBfKey
cBfKey := hb_blowfishKey(cPass)
Return hb_blowfishDecrypt(cBfKey, cEncoded:=hb_HexToStr(cEncoded))