Class CipherSmServiceImpl
java.lang.Object
cn.sinozg.applet.common.service.impl.CipherSmServiceImpl
- All Implemented Interfaces:
CipherService
@Service
@ConditionalOnProperty(prefix="app.sign",
name="crypto-type",
havingValue="sm")
public class CipherSmServiceImpl
extends Object
implements CipherService
国密实现 系统加密
使用sm3 签名
- Since:
- 2024-12-04 14:27
- Author:
- xieyubin
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]decryptJson(String content, String asymmetricPrivateKey, String symmetricEncrypt) 先用非对称私钥(java)解密前端传过来的 对称加密加密信息,得到前端生成的随机对称加密 keyencoder(CharSequence plainText) 加密信息 密码随机生成16位的 对称加密私钥booleanmatches(CharSequence plainText, String encodedPassword) 密码匹配boolean签名判断 参数排序拼接后 签名再与原始的签名比较Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface cn.sinozg.applet.common.service.CipherService
encryptJson
-
Field Details
-
log
private static final org.slf4j.Logger log
-
-
Constructor Details
-
CipherSmServiceImpl
public CipherSmServiceImpl()
-
-
Method Details
-
encoder
Description copied from interface:CipherService加密信息 密码- Specified by:
encoderin interfaceCipherService- Parameters:
plainText- 密码- Returns:
- 加密后的数据
-
matches
Description copied from interface:CipherService密码匹配- Specified by:
matchesin interfaceCipherService- Parameters:
plainText- 原始密码encodedPassword- 加密后的密码- Returns:
- 是否匹配
-
signature
Description copied from interface:CipherService签名判断 参数排序拼接后 签名再与原始的签名比较- Specified by:
signaturein interfaceCipherService- Parameters:
sha2- 是否为 sha2signature- 签名字符串params- 要签名的数据- Returns:
- 是否与签名一致
-
decryptJson
public byte[] decryptJson(String content, String asymmetricPrivateKey, String symmetricEncrypt) throws Exception 先用非对称私钥(java)解密前端传过来的 对称加密加密信息,得到前端生成的随机对称加密 key
再用 对称加密 key解密得到数据
- Specified by:
decryptJsonin interfaceCipherService- Parameters:
content- 内容asymmetricPrivateKey- 非对称私钥symmetricEncrypt- 对称加密后的数据- Returns:
- 解密后的数据
- Throws:
Exception- 异常
-
encrypt
随机生成16位的 对称加密私钥用对称加密私钥 加密json得到加密信息
用前端传过来的 RSA 公钥加密 aes私钥 得到aes私钥加密信息
- Specified by:
encryptin interfaceCipherService- Parameters:
content- 加密信息asymmetricPublicKey- 前端传过来的非对称加密公钥- Returns:
- 加密信息
- Throws:
Exception
-