获取到的加密字符串是:
V02_3081D302204C0E940DEF67CC50B8C5639810B02FE17E86368A0CC9BAB7D79EE20EFA4BA379022100885D7E995AC8401DDC51DA242C3138DFB9888999284976E0655C2D7E71A475150420E6097CB081058BC3D5B7CD788654102D3CCE6DD517772C1627B2D131F362287E046ABD14E9E4733873A3DE9EE267C602D1A9296A28D7D53C0512D57A1F4086BBF1CE497E201894B5BBDC1A357484885C142F7606D094BCDE82A2FB13DE16FBFD3E2CDBA56B481C913CC873331F007B5B8284832563A0B98A528C35813B175E31E0131585B8F0CEBA10B8E1E3
然后后台java解密出现异常是:
java.lang.ClassCastException: org.bouncycastle.asn1.DLApplicationSpecific cannot be cast to org.bouncycastle.asn1.ASN1Sequence
BigInteger privateKeyD = new BigInteger(privateKeyStr, 16);
ECPrivateKeyParameters privateKeyParameters = new ECPrivateKeyParameters(privateKeyD, ecDomainParameters);
//解密-------------------------------------------------------------------------------------------------------
//用私钥解密
ZSM2Engine sm2EngineDec = new ZSM2Engine();
sm2EngineDec.init(false, privateKeyParameters);
byte[] arrayOfBytes = null;
try {
arrayOfBytes = sm2EngineDec.processBlock(encryptData, 0, encryptData.length);
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidCipherTextException e) {
e.printStackTrace();
}
//得到明文:SM2 Encryption Test
data = new String(arrayOfBytes);
return data;
求助 给一个前端加密,后台java解密的例子。谢谢
参考一下;https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/safe-password.html
好歹给一个后端的例子啊,怎么加密怎么解密的例子啊