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.
Sqlite unrecognized token
Moderator: Rathinagiri
- karweru
- Posts: 220
- Joined: Fri Aug 01, 2008 1:51 pm
- DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
- Contact:
Sqlite unrecognized token
Kind regards,
Gilbert.
Gilbert.
- mustafa
- Posts: 1158
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: Sqlite unrecognized token
Samples
Mustafa
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
- karweru
- Posts: 220
- Joined: Fri Aug 01, 2008 1:51 pm
- DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
- Contact:
Re: Sqlite unrecognized token
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))
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.
Gilbert.