java.lang.Object
com.codingapi.springboot.framework.crypto.RSA

public class RSA extends Object
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • generateKey

      public KeyPair generateKey() throws NoSuchAlgorithmException
      Generate key which contains a pair of privae and public key using 2048 bytes
      返回:
      key pair
      抛出:
      NoSuchAlgorithmException
    • getPrivateKey

      public byte[] getPrivateKey()
    • getPublicKey

      public byte[] getPublicKey()
    • encrypt

      public byte[] encrypt(byte[] text) throws Exception
      Encrypt a text using public key.
      参数:
      text - The original unencrypted text
      返回:
      Encrypted text
      抛出:
      Exception
    • decrypt

      public byte[] decrypt(byte[] text) throws Exception
      Decrypt text using private key
      参数:
      text - The encrypted text
      返回:
      The unencrypted text
      抛出:
      Exception