[英]react native - validate source using digital signature with JWS, bcrypt or react-native-crypto
[英]Validate public key with the signature -react native biometrics
我正在尝试使用react native biometrics,但是在我创建并存储了公钥(作为下面示例代码中的状态)之后,它永远不会与之后用同一根手指生成的签名匹配。 如何验证指纹?
代码:
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>
);
}
}
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.