Private Sub EncryptString(myString As String) As String
Dim myEncryptedDataByte() As Byte
Dim c As B4XCipher
myEncryptedDataByte = c.Encrypt(myString.GetBytes("utf-8"), strPassword)
Dim su As StringUtils
Return su.EncodeBase64(myEncryptedDataByte)
End Sub
Private Sub DecryptString(myString As String) As String
Dim myByteToBeDecrypted() As Byte
Dim su As StringUtils
myString = DeEscapeField(myString) 'Sub per eliminare eventuali parentesi quadre all'inizio e alla fine del record
If IsNumber(myString) Then ' Per i casi in cui bisogna leggere i rowid e dati non crittografati
Return myString
Else
Try
myByteToBeDecrypted = su.DecodeBase64(myString)
Catch
Log(LastException)
End Try
Dim c As B4XCipher
Try
Dim b() As Byte = c.Decrypt(myByteToBeDecrypted, strPassword)
Catch
Log(LastException)
End Try
Try
Private myString2 As String = BytesToString(b, 0, b.Length, "utf-8")
Catch
Log(LastException)
End Try
End If
Return myString2
End Sub