Has anyone had difficulty getting the hash results from swift to match the same input hash result in PHP? Here's my swift code:
let longPassword = myTextField.text!+email
let pword: Array<UInt8> = Array(longPassword.utf8)
let keyString = self.runHashOnPassword(text: pword, salt: Array(salt.utf8))
func runHashOnPassword(text: Array<UInt8>, salt: Array<UInt8>) -> String {
do {
let key = try PKCS5.PBKDF2(password: text,salt: salt, iterations: 4096, variant: .sha256).calculate()
let jEncoder = JSONEncoder.init()
let byteString = try jEncoder.encode(key)
return byteString.base64EncodedString()
} catch {
return ""
}
}
And here is my PHP code:
$longPassword = $pword . $email . $salt;
$newHash = hash('sha256',$longPassword,false);
I have tried altering the boolean flag to true in the PHP hash function but it didn't help. Any ideas? Thank you.