类 RsaUtil

java.lang.Object
cn.hamm.airpower.util.RsaUtil

@Component public class RsaUtil extends Object

RSA加解密助手类

作者:
Hamm.cn
  • 构造器详细资料

    • RsaUtil

      public RsaUtil()
  • 方法详细资料

    • publicKeyEncrypt

      public final String publicKeyEncrypt(String sourceContent)

      公钥加密

      参数:
      sourceContent - 原文
      返回:
      密文
    • privateKeyDecrypt

      @NotNull public final @NotNull String privateKeyDecrypt(String encryptedContent)

      私钥解密

      参数:
      encryptedContent - 密文
      返回:
      原文
    • privateKeyEncrypt

      public final String privateKeyEncrypt(String sourceContent)

      私钥加密

      参数:
      sourceContent - 原文
      返回:
      密文
    • publicKeyDecrypt

      @NotNull public final @NotNull String publicKeyDecrypt(String encryptedContent)

      公钥解密

      参数:
      encryptedContent - 密文
      返回:
      原文
    • generateKeyPair

      public final KeyPair generateKeyPair() throws NoSuchAlgorithmException

      生成RSA密钥对

      返回:
      KeyPair
      抛出:
      NoSuchAlgorithmException
    • convertPublicKeyToPEM

      @NotNull public final @NotNull String convertPublicKeyToPEM(@NotNull @NotNull PublicKey publicKey)

      将公钥转换为PEM格式

      参数:
      publicKey - 公钥
      返回:
      PEM
    • convertPrivateKeyToPEM

      @NotNull public final @NotNull String convertPrivateKeyToPEM(@NotNull @NotNull PrivateKey privateKey)

      将私钥转换为PEM格式

      参数:
      privateKey - 私钥
      返回:
      PEM