B4J Question Encryption. Sample fails.

Karl Wagner

Member
Licensed User
Hi,

I am trying this code, just as posted on this forum.
It fails. I have attached a screenshot.

Thanks


B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim cifro As B4XCipher
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
  
End Sub

Sub Activity_Create(FirstTime As Boolean)

  
  
End Sub

Sub Encrypt(text As String, password As String) As Byte()
    Dim c As B4XCipher
    Return c.Encrypt(text.GetBytes("utf8"), password)
End Sub

Sub Decrypt(EncryptedData() As Byte, password As String) As String
    Dim c As B4XCipher
    Dim b() As Byte = c.Decrypt(EncryptedData, password)
    Return BytesToString(b, 0, b.Length, "utf8")
End Sub

Dim EncryptedData() As Byte = Encrypt("confidential", "123456")
Log(Decrypt(EncryptedData, "123456"))
 

Attachments

Last edited:

Karl Wagner

Member
Licensed User
Hi Erel,

Thanks for writing.
The code I posted is your code.
It's a sample you posted on this forum.
The screenshot displays the error.

Thanks.
 

Erel

Administrator
Staff member
Licensed User

Karl Wagner

Member
Licensed User
Ok!, let me double check that link!
My target will be B4A. Not for B4J.
I was testing it on B4J to avoid transfer via bridge to the phone on B4A and have a quicker test cycle.

Thanks!
 
Top