Android Question Encryption B4A and B4I

David Hawkins

Active Member
Licensed User
Longtime User
Hi I am using the following code to encrypt a password so that it can be compared to a saved password in a database

Encryption:
Sub EncryptText(sPassword As String, passcode As String) As Byte()
    Dim c As B4XCipher
    Return c.Encrypt(sPassword.GetBytes("utf8"), passcode)
End Sub

and whilst the encryption is working OK the encrypted string is never the same so it can't be compared to that saved in the database, is there an encryption library which will enable me to use it in both B4A and B4I? without the encrypted string changing

I hope I have made that clear

Regards
David
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Hi I am using the following code to encrypt a password so that it can be compared to a saved password in a database
Why? Best practice is to store the hash of the password + salt. This way the original password can never be revealed.

You can calculate the hash with the Encryption library in B4A / B4J and iEncryption in B4i.
 
Upvote 0
Top