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 Details

    • CipherDefaultServiceImpl

      public CipherDefaultServiceImpl()
  • Method Details

    • encoder

      public String encoder(CharSequence plainText)
      Description copied from interface: CipherService
      加密信息 密码
      Specified by:
      encoder in interface CipherService
      Parameters:
      plainText - 密码
      Returns:
      加密后的数据
    • matches

      public boolean matches(CharSequence plainText, String encodedPassword)
      Description copied from interface: CipherService
      密码匹配
      Specified by:
      matches in interface CipherService
      Parameters:
      plainText - 原始密码
      encodedPassword - 加密后的密码
      Returns:
      是否匹配
    • signature

      public boolean signature(boolean sha2, String signature, String... params)
      Description copied from interface: CipherService
      签名判断 参数排序拼接后 签名再与原始的签名比较
      Specified by:
      signature in interface CipherService
      Parameters:
      sha2 - 是否为 sha2
      signature - 签名字符串
      params - 要签名的数据
      Returns:
      是否与签名一致
    • decryptJson

      public byte[] decryptJson(String content, String asymmetricPrivateKey, String symmetricEncrypt) throws Exception
      Description copied from interface: CipherService
      解密前端传过来的加密数据

      先用非对称私钥私钥(java)解密前端传过来的对称加密信息,得到前端生成的随机对称加密 key

      再用 对称加密 key解密得到数据

      Specified by:
      decryptJson in interface CipherService
      Parameters:
      content - 内容
      asymmetricPrivateKey - 非对称私钥
      symmetricEncrypt - 对称加密后的数据
      Returns:
      解密后的数据
      Throws:
      Exception - 异常
    • encrypt

      public RequestParameterEncrypt encrypt(String content, String symmetricPublicKey) throws Exception
      Description copied from interface: CipherService
      随机生成 对称加密私钥

      用对称加密 私钥加密json得到加密信息

      用前端传过来的 非对称公钥加密 对称加密私钥 得到对称加密私钥加密信息

      Specified by:
      encrypt in interface CipherService
      Parameters:
      content - 加密信息
      symmetricPublicKey - 前端传过来的非对称加密公钥
      Returns:
      加密信息
      Throws:
      Exception