我正在尝试使用react native biometrics,但在我创建并存储了公钥(作为下面示例代码中的状态)后,它永远不会与随后使用相同手指生成的签名相匹配。如何验证fingerPrint?
代码:
registerFingerPrint = () => {
Biometrics.isSensorAvailable()
.then((biometryType) => {
if (biometryType === Biometrics.TouchID) {
Biometrics.createKeys('Confirm fingerprint')
.then((publicKey) => {
console.log("create", publicKey)
this.setState({
create: publicKey
})
})
}
})
}
fingerPrintCheck = () => {
Biometrics.createSignature('Sign in', payload)
.then((signature) => {
if (this.state.create === signature){
console.log("success");
}else {
console.log('failure'); //always returns failure here
}
})
}
render() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={()=> this.registerFingerPrint()}>
<Text style={{ marginBottom: 10}}>
Register
</Text>
</TouchableHighlight>
<TouchableHighlight onPress={()=> this.fingerPrintCheck()}>
<Text>
Authenticate with Biometrics
</Text>
</TouchableHighlight>
</View>
);
}
}发布于 2020-01-28 19:35:41
let epochTimeSeconds = Math.round((new Date()).getTime() / 1000).toString()
let payload = epochTimeSeconds +'some message' ;
Biometrics.createSignature('Sign in Test', payload)
.then((signature) => {
console.log(payload+" signature "+signature)
verifySignatureWithServer(signature, payload)
})您需要使用生成的签名和负载组合在服务器端检查验证。
转到此站点并粘贴生成的公钥、签名、有效负载并进行验证。
https://8gwifi.org/RSAFunctionality?rsasignverifyfunctions=rsasignverifyfunctions&keysize=512

https://stackoverflow.com/questions/54972376
复制相似问题