HI,
We are facing a login issue with our IOS App and our Web App.
We hash the usernames and passwords because they are sent using cookies from the login to the main Web App for authentication.
We proceed that way :
1- When the user logs in, we hash both the entered username and password and compare them to the hashed values stored in the database.
2- We create a cookie containing the hashed user name and call the URL of the main app.
3- When the main app opens, it reads the cookie, compares it against the database to identify the user and remove the cookie.
We would like to reproduce this scenario with our IOS App but we are unable to generate the same hashed values in IOS.
Here is some code we are using :
Web App Encrypting
[code]Function EncryptString(value As String) As String
Using Xojo.Core
Using Xojo.Crypto
Dim kSSMB As Xojo.Core.MemoryBlock
kSSMB = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(kSS)
Dim valueMB As Xojo.Core.MemoryBlock
valueMB = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(value.ToText)
Dim hash As Xojo.Core.MemoryBlock
hash = Xojo.Crypto.PBKDF2(kSSMB, valueMB, 100, 32, Xojo.Crypto.HashAlgorithms.SHA512)
Dim hashValue As String
hashValue = EncodeBase64(Xojo.Core.TextEncoding.UTF8.ConvertDataToText(hash, True),0)
Return hashValue
End Sub
[/code]
IOS Encrypting
[code]Dim hashValue As Text
Dim hash As MemoryBlock
Dim kSSMB As MemoryBlock
kSSMB = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(kSS)
Dim password As Text = value
Dim passwordMB As MemoryBlock
passwordMB = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(password)
hash = Crypto.PBKDF2(saltMB, passwordMB, 100, 32, HashAlgorithms.SHA512)
hashValue = encodeBase64(hash)
Return hashValue[/code]
I guess it has something to do with the encodings and text conversion…
What would be the way to achieve that?
Thanks!