Module bus.crypto

Class TEA

java.lang.Object
org.miaixz.bus.crypto.center.TEA
All Implemented Interfaces:
Serializable, Decryptor, Encryptor

public class TEA extends Object implements Encryptor, Decryptor, Serializable
TEA(Corrected Block Tiny Encryption Algorithm)算法实现 来自:https://github.com/xxtea/xxtea-java
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • TEA

      public TEA(byte[] key)
      构造
      Parameters:
      key - 密钥,16位
  • Method Details

    • encrypt

      public byte[] encrypt(byte[] data)
      Description copied from interface: Encryptor
      加密
      Specified by:
      encrypt in interface Encryptor
      Parameters:
      data - 被加密的bytes
      Returns:
      加密后的bytes
    • encrypt

      public void encrypt(InputStream data, OutputStream out, boolean isClose)
      Description copied from interface: Encryptor
      加密,针对大数据量,可选结束后是否关闭流
      Specified by:
      encrypt in interface Encryptor
      Parameters:
      data - 被加密的字符串
      out - 输出流,可以是文件或网络位置
      isClose - 是否关闭流
    • decrypt

      public byte[] decrypt(byte[] data)
      Description copied from interface: Decryptor
      解密
      Specified by:
      decrypt in interface Decryptor
      Parameters:
      data - 被解密的bytes
      Returns:
      解密后的bytes
    • decrypt

      public void decrypt(InputStream data, OutputStream out, boolean isClose)
      Description copied from interface: Decryptor
      解密,针对大数据量,结束后不关闭流
      Specified by:
      decrypt in interface Decryptor
      Parameters:
      data - 加密的字符串
      out - 输出流,可以是文件或网络位置
      isClose - 是否关闭流,包括输入和输出流