Class AbstractAeadCipher

java.lang.Object
com.wechat.pay.java.core.cipher.AbstractAeadCipher
All Implemented Interfaces:
AeadCipher
Direct Known Subclasses:
AeadAesCipher

public abstract class AbstractAeadCipher extends Object implements AeadCipher
带有关联数据的认证加密器
  • Constructor Details

    • AbstractAeadCipher

      protected AbstractAeadCipher(String algorithm, String transformation, int tagLengthBit, byte[] key)
  • Method Details

    • encrypt

      public String encrypt(byte[] associatedData, byte[] nonce, byte[] plaintext)
      加密并转换为字符串
      Specified by:
      encrypt in interface AeadCipher
      Parameters:
      associatedData - AAD,额外的认证加密数据,可以为空
      nonce - IV,随机字符串初始化向量
      plaintext - 明文
      Returns:
      Base64编码的密文
    • decrypt

      public String decrypt(byte[] associatedData, byte[] nonce, byte[] ciphertext)
      解密并转换为字符串
      Specified by:
      decrypt in interface AeadCipher
      Parameters:
      associatedData - AAD,额外的认证加密数据,可以为空
      nonce - IV,随机字符串初始化向量
      ciphertext - 密文
      Returns:
      UTF-8编码的明文