1 package java.util.zip;
   2 
   3 
   4 /**
   5  * Interface for ZIP encrypt/decrypt engine.
   6  *
   7  * @since 1.9
   8  */
   9 public interface ZipCryption {
  10 
  11     /**
  12      * Calculate encription header
  13      *
  14      * @param e ZIP entry
  15      * @return ZIP encryption header
  16      */
  17     public byte[] getEncryptionHeader(ZipEntry e);
  18 
  19     /**
  20      * Encrypt byte array.
  21      * @param data Byte array to encrypt
  22      * @param offset offset to start
  23      * @param length array length
  24      * @return Encrypted array. This instance is same to argument.
  25      */
  26     public byte[] encryptBytes(byte[] data, int offset, int length);
  27 
  28     /**
  29      * Encrypt byte array.
  30      * @param data Byte array to encrypt
  31      * @return Encrypted array. This instance is same to argument.
  32      */
  33     public byte[] encryptBytes(byte[] data);
  34 
  35     /**
  36      * Reset encryption engine.
  37      */
  38     public void reset();
  39 
  40     /**
  41      * Get ZIP encryption header.
  42      * @return sizeof encryption header.
  43      */
  44     public int getEncryptionHeaderSize();
  45 
  46     /**
  47      * Check encryption header
  48      *
  49      * @param e ZipEntry
  50      * @param encryptionHeader encryption header to be check
  51      * @return true if this encryption header is valid.
  52      */
  53     public boolean isValid(ZipEntry e, byte[] encryptionHeader);
  54 
  55     /**
  56      * Decrypt byte array.
  57      * @param data Byte array to decrypt
  58      * @param offset offset to start
  59      * @param length array length
  60      * @return Decrypted array. This instance is same to argument.
  61      */
  62     public byte[] decryptBytes(byte[] data, int offset, int length);
  63 
  64     /**
  65      * Decrypt byte array.
  66      * @param data Byte array to decrypt
  67      * @return Decrypted array. This instance is same to argument.
  68      */
  69     public byte[] decryptBytes(byte[] data);
  70 
  71 }