Class SecretKeyUtil

java.lang.Object
io.github.xezzon.zeroweb.core.crypto.SecretKeyUtil

public class SecretKeyUtil extends Object
读写密钥工具类
Author:
xezzon
  • Field Details

    • keyConverter

      public static final org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter keyConverter
  • Method Details

    • readPublicKey

      public static PublicKey readPublicKey(ASN1PublicKeyReader reader) throws org.bouncycastle.openssl.PEMException
      从ASN1PublicKeyReader中读取公钥
      Parameters:
      reader - ASN1PublicKeyReader对象,用于读取公钥
      Returns:
      返回读取到的公钥
      Throws:
      org.bouncycastle.openssl.PEMException - 如果读取公钥失败,抛出PEMException异常
    • readPrivateKey

      public static PrivateKey readPrivateKey(ASN1PrivateKeyReader reader) throws org.bouncycastle.openssl.PEMException
      从ASN1PrivateKeyReader中读取私钥
      Parameters:
      reader - ASN1PrivateKeyReader对象,用于读取私钥
      Returns:
      返回读取到的私钥
      Throws:
      org.bouncycastle.openssl.PEMException - 如果读取私钥失败,抛出PEMException异常
    • writePublicKey

      public static void writePublicKey(PublicKey publicKey, ASN1PublicKeyWriter writer) throws org.bouncycastle.openssl.PEMException
      将公钥写入ASN1PublicKeyWriter中。
      Parameters:
      publicKey - 要写入的公钥对象。
      writer - 用于写入公钥的ASN1PublicKeyWriter对象。
      Throws:
      org.bouncycastle.openssl.PEMException - 如果写入公钥失败,抛出PEMException异常。
    • writePrivateKey

      public static void writePrivateKey(PrivateKey privateKey, ASN1PrivateKeyWriter writer) throws org.bouncycastle.openssl.PEMException
      将私钥写入ASN1PrivateKeyWriter中。
      Parameters:
      privateKey - 要写入的私钥对象。
      writer - 用于写入私钥的ASN1PrivateKeyWriter对象。
      Throws:
      org.bouncycastle.openssl.PEMException - 如果写入私钥失败,抛出PEMException异常。