-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
// 密钥对生成地址 https://www.lzltool.com/SM2
private static final String PRIVATE_KEY = "";
private static final String PUBLIC_KEY = "";
public static String decryptStr(String cipherTextHex) {
try {
SM2 sm2 = SmUtil.sm2(PRIVATE_KEY, null); // 只需要私钥
sm2.setMode(SM2Engine.Mode.C1C2C3); // 设置解密模式,JS 加密model 选:0
byte[] decryptedBytes = sm2.decrypt(HexUtil.decodeHex(cipherTextHex), KeyType.PrivateKey);
return Base64.decodeStr(StrUtil.utf8Str(decryptedBytes)); // 转换为字符串
}catch (Exception e){
log.error("decryptStr error: ", e);
}
return null;
}
Metadata
Metadata
Assignees
Labels
No labels