Hi everyone! I'm trying to get my B4A app to use the salt string (char(120) in mysql) in lower case letters, all hex, to concatenate the value stored in a EditText view called Password on an activity layout. I would then hash this combination by passing it to the byteconverter. The result would be the wrong password when compared to the stored hashed password in mysql, all in hex. The resulting letters have also ended up in upper case.
Here's the code
The same mysql database is being used on my website and the PHP hash() function works perfectly with the db stored hash and the password from the input field on the webform:
Is there something I'm missing in my code that would solve this one?
Here's the code
B4X:
Dim dbsalt As String ' a value from the salt field in the User table record is assigned here
Dim hash() As Byte
Dim password As String
Dim saltpassword As String
Dim saltpasswordbyte() As Byte
Dim mdencrypt As MessageDigest
Dim bc As ByteConverter
saltpassword = txtPassword.Text & dbsalt 'This is the combination of txtPassword from the form and the salt value from the db
saltpasswordbyte = saltpassword.GetBytes("UTF8") ' convert to bytes for the byteconverter
hash = mdencrypt.GetMessageDigest(saltpasswordbyte, "SHA-512") ' hash the byte value with SHA-512
password = bc.HexFromBytes(hash) ' convert the hashed byte value to hex and store in password string
The same mysql database is being used on my website and the PHP hash() function works perfectly with the db stored hash and the password from the input field on the webform:
B4X:
// PHP code from my website that is used for secure login
// hash the password with the unique salt.
$password = hash('sha512', $password . $salt);
Is there something I'm missing in my code that would solve this one?
Last edited: