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