Sqlite unrecognized token

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
karweru
Posts: 167
Joined: Fri Aug 01, 2008 1:51 pm
DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
Been thanked: 4 times
Contact:

Sqlite unrecognized token

Post by karweru » Tue Apr 09, 2019 10:08 pm

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.
Kind regards,
Gilbert.

User avatar
mustafa
Posts: 790
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 109 times
Contact:

Post by mustafa » Wed Apr 10, 2019 11:07 am


User avatar
mustafa
Posts: 790
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 109 times
Contact:

Post by mustafa » Wed Apr 10, 2019 12:12 pm

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

User avatar
karweru
Posts: 167
Joined: Fri Aug 01, 2008 1:51 pm
DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
Been thanked: 4 times
Contact:

Post by karweru » Wed Apr 10, 2019 5:00 pm

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))
Kind regards,
Gilbert.

Post Reply