0

I am currently storing five text fields in a table along with a number of numeric fields.

I've now find that that these five text fields need to be encrypted. If I encrypt each text field and then use base64encode, do I need to store the result in a BLOB or a TEXT field?

At this time I have set up the table with five BLOB fields. When I update one of the fields I use the following code;

put base64encode(tValue) into t64EncValue
put "UPDATE myTable SET blobTextfield01 = :1 WHERE recID = :2" into tSQL
revExecuteSQL gDatabaseID, tSQL, "*bt64EncValue", gCurrentID

When I read back the data (execute another SQL read) I can see that t64EncValue has some data but when I do a base64Decode, tText01 is left blank.

put base64decode(t64EncValue) into tText01

I'm not sure if I have a problem with the way the data is saved, the way it's retrieved, or whether base64decode has an issue...

Mark
  • 2,380
  • 11
  • 29
  • 49
  • What else can you tell about the data in t64EncValue? What is the length? What is `the result`after you execute `base64decode(t64EncValue)`? – Mark Apr 14 '14 at 09:37
  • I started with the string: "Text String 01" after the encode the string became "VGV4dCBTdHJpbmcgMDAw". After the read the string was a series of unprintable characters. the result after decode was blank. I'm beginning to suspect that the UPDATE didn't work in the first place. – Alex Alexander Apr 14 '14 at 12:23
  • Do you mean that `t64EncValue`contains "VGV4dCBTdHJpbmcgMDAw"? If so, all seems to work correctly, because `put base64decode("VGV4dCBTdHJpbmcgMDAw")`yields "Text String 000" Perhaps you should explain your problem again. – Mark Apr 14 '14 at 14:43
  • I agree. The encode bit works. Can you see anything wrong with the UPDATE and revExecuteSQL? Because I don't think thats working as expected. – Alex Alexander Apr 14 '14 at 23:00
  • Why do you think that? – Mark Apr 15 '14 at 01:22
  • I've now checked the return code which is zero and looked again in the table. The field that should have been updated is null. So for whatever reason the UPDATE isn't updating anything. My original comment was based on old data. – Alex Alexander Apr 15 '14 at 04:35
  • I changed the code as follows: put "UPDATE myTable SET blobTextfield01 = :1 WHERE recID = " & gCurrentID into tSQL. The return code is now '1' and lo and behold the UPDATE did work as did the subsequent decode. Thanks for your help. – Alex Alexander Apr 15 '14 at 04:41
  • While I'm still thinking about this, do you really have a table named `myTable`? Perhaps you could start with using all lower case characters for the table name. If myTable is actually a variable name, change your script into `put "UPDATE" && quote & myTable & quote &&....` – Mark Apr 15 '14 at 13:03
  • Thanks Mark. No, I don't have a table called myTable. The change I made {put "UPDATE myTable SET blobTextfield01 = :1 WHERE recID = " & gCurrentID into tSQL} worked. – Alex Alexander Apr 16 '14 at 03:50
  • Does that mean that your problem is solved now? – Mark Apr 16 '14 at 11:36

0 Answers0