Is there an easy way to encrypt a table file? If I use the XML-Table, every data can watch with the internet explorer.
And is it better to use CSV than XML for encrypt?
I have worked with the crypt-lib to encrypt and decrypt one password, but is that also the solution for a whole database?
Thanks, Erel! But I only use a very small table with 4 cols and 20 to 30 rows. I think it's not enough to use sql.
But I tried now to encrypt every cell with the following code:
B4X:
Sub Globals
Dim string(0) As Byte, secret(0) As Byte
PassPhrase = "my key"
end sub
Sub Encrypt
For x=0 To Table1.RowCount-1
For y=0 To table1.ColCount-1
Data=Table1.Cell(Table1.ColName(y),x)
string() = Bit.StringToBytes(Data,0,StrLength(Data))
secret() = Crypto.Encrypt(PassPhrase, string())
For i = 0 To ArrayLen(secret())-1
s = s & bit.DecToHex(secret(i))
Next
Table1.Cell(Table1.ColName(y),x) = s
Next
Next
End Sub
But only the first col will encrypt exactly, the other cells becomes longer and longer with each row. s="" doesn't help.:BangHead:
You are not resetting 's' between different cells. So it keeps growing and growing.
Adding s = "" at the line 88 (right after the second For) seems to solve this problem.
But s="" doesn't work, I have tried it before.
I add s="" in line 88 and show s in line 95 with msgbox(s).
After encrypt some cells, you see that 's' is always growing, but not for all cells. The first cell of a row will encrypt right, the second to fourth cell of the row grows up after some clicks.. I don't find the problem....
First, as Erel says, there is a missing initalisation of s in the inner loop.
Second the Table is set to sort on the first column so as you encrypt and overwrite the first column the table resorts itself so you now encrypt already encrypted data.
You need to do something like this
SortCol = "Modul ASC"
Table1.TableSort (SortCol)
...
Table1.TableSort ("")
... ' do encrypt or decrypt stuff
Table1.TableSort (SortCol)
Second the Table is set to sort on the first column so as you encrypt and overwrite the first column the table resorts itself so you now encrypt already encrypted data.