Sqlite unrecognized token

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

Sqlite unrecognized token

Post 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.
Kind regards,
Gilbert.
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Sqlite unrecognized token

Post by mustafa »

User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Sqlite unrecognized token

Post 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
User avatar
karweru
Posts: 220
Joined: Fri Aug 01, 2008 1:51 pm
DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
Contact:

Re: Sqlite unrecognized token

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