Android Question Questions about B4A Encryption

Javier Campo Martinez

Member
Licensed User
Hi everybody !!!
I am trying to encrypt some text in order to store it in SQLite database as a password, for further login validations.

But everytime i call this code, i get a different encrypted output text, using the same value as input.

My code to encrypt:
Sub Encriptar(iCadena As String) As String
    Dim cifro As B4XCipher
    Dim su As StringUtils
    Dim b() As Byte = cifro.Encrypt(iCadena.GetBytes("utf8"), "xxxxx")
    Return su.EncodeBase64(b)
End Sub

Any ideas?
Thanks in advance, and best regards.
 

Peter Simpson

Expert
Licensed User
Longtime User
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But everytime i call this code, i get a different encrypted output text, using the same value as input.
True. This is because it uses a random salt and random initialization vector. Both are saved together with the encrypted data. It is more secure like this.

 
Upvote 0
Top