You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used your plug-in in my front-end development code to generate signatures and unsign them. However, in Java, the uncheck fails and the data is not correct when converting the byte array and the signature front-end code generated by Java can also be unsigned, so how should Java adjust。 const signWithPrivateKey = (privateKey, data) => {
const encrypt = new JSEncrypt();
encrypt.setPrivateKey(privateKey) ;
return encrypt.sign(data,CryptoJS.SHA1);
};
// 使用公钥进行验证签名
const verifyWithPublicKey = (publicKey, data, signature) => {
const encrypt = new JSEncrypt();
encrypt.setPublicKey(publicKey);
return encrypt.verify(data, signature, CryptoJS.SHA1);
}; Java code:@Override
protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
if (publicKey == null) {
throw new SignatureException("Missing public key");
}
try {
if (sigBytes.length != RSACore.getByteLength(publicKey)) {
throw new SignatureException("Signature length not correct: got " +
sigBytes.length + " but was expecting " +
RSACore.getByteLength(publicKey));
}
byte[] digest = getDigestValue();
byte[] decrypted = RSACore.rsa(sigBytes, publicKey);
byte[] unpadded = padding.unpad(decrypted);
byte[] decodedDigest = decodeSignature(digestOID, unpadded);
return MessageDigest.isEqual(digest, decodedDigest);
} catch (javax.crypto.BadPaddingException e) {
// occurs if the app has used the wrong RSA public key
// or if sigBytes is invalid
// return false rather than propagating the exception for
// compatibility/ease of use
return false;
} catch (IOException e) {
throw new SignatureException("Signature encoding error", e);
} finally {
resetDigest();
}
}
The text was updated successfully, but these errors were encountered:
I used your plug-in in my front-end development code to generate signatures and unsign them. However, in Java, the uncheck fails and the data is not correct when converting the byte array and the signature front-end code generated by Java can also be unsigned, so how should Java adjust。 const signWithPrivateKey = (privateKey, data) => {
const encrypt = new JSEncrypt();
encrypt.setPrivateKey(privateKey) ;
return encrypt.sign(data,CryptoJS.SHA1);
};
The text was updated successfully, but these errors were encountered: