Class CipherDefaultServiceImpl
java.lang.Object
cn.sinozg.applet.common.service.impl.CipherDefaultServiceImpl
- All Implemented Interfaces:
CipherService
@Service
@ConditionalOnSingleCandidate(CipherService.class)
public class CipherDefaultServiceImpl
extends Object
implements CipherService
默认实现加密
- Since:
- 2024-12-04 14:13
- Author:
- xieyubin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]decryptJson(String content, String asymmetricPrivateKey, String symmetricEncrypt) 解密前端传过来的加密数据encoder(CharSequence plainText) 加密信息 密码随机生成 对称加密私钥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
-
Constructor Details
-
CipherDefaultServiceImpl
public CipherDefaultServiceImpl()
-
-
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 Description copied from interface:CipherService解密前端传过来的加密数据先用非对称私钥私钥(java)解密前端传过来的对称加密信息,得到前端生成的随机对称加密 key
再用 对称加密 key解密得到数据
- Specified by:
decryptJsonin interfaceCipherService- Parameters:
content- 内容asymmetricPrivateKey- 非对称私钥symmetricEncrypt- 对称加密后的数据- Returns:
- 解密后的数据
- Throws:
Exception- 异常
-
encrypt
Description copied from interface:CipherService随机生成 对称加密私钥用对称加密 私钥加密json得到加密信息
用前端传过来的 非对称公钥加密 对称加密私钥 得到对称加密私钥加密信息
- Specified by:
encryptin interfaceCipherService- Parameters:
content- 加密信息symmetricPublicKey- 前端传过来的非对称加密公钥- Returns:
- 加密信息
- Throws:
Exception
-