Interface SimpleCrypt


public interface SimpleCrypt
Crypt
Since:
1.0.0
Author:
PARK Yong Seo
  • Method Summary

    Modifier and Type Method Description
    static SimpleCrypt decrypt​(java.lang.String transformation, byte[] key, byte[] iv)
    decrypt
    static SimpleCrypt encrypt​(java.lang.String transformation, byte[] key, byte[] iv)
    encrypt
    void to​(java.io.File in, java.io.File out, boolean overwrite)
    input file -> (en/de)crypt -> output file
    void to​(java.io.InputStream is, java.io.OutputStream os)
    input -> (en/de)crypt -> output
    default java.lang.String toBase64​(byte[] data)
    to base64 string
    input bytes -> (en/de)crypt -> output base64 string
    default java.lang.String toBase64​(byte[] data, int offset, int length)
    to base64 string
    input bytes -> (en/de)crypt -> output base64 string
    default java.lang.String toBase64ByBase64​(java.lang.String base64)
    to base64 string
    input base64 string -> (en/de)crypt -> output base64 string
    default java.lang.String toBase64ByHex​(java.lang.String hex)
    to base64 string
    input hex string -> (en/de)crypt -> output base64 string
    byte[] toBytes​(byte[] data)
    to byte
    input bytes -> (en/de)crypt -> output bytes
    byte[] toBytes​(byte[] data, int offset, int length)
    to byte
    input bytes -> (en/de)crypt -> output bytes
    default byte[] toBytesByBase64​(java.lang.String base64)
    to byte
    input base64 string -> (en/de)crypt -> output bytes
    default byte[] toBytesByHex​(java.lang.String hex)
    to byte
    input hex string -> (en/de)crypt -> output bytes
    default java.lang.String toHex​(byte[] data)
    to hex string
    input bytes -> (en/de)crypt -> output hex string
    default java.lang.String toHex​(byte[] data, int offset, int length)
    to hex string
    input bytes -> (en/de)crypt -> output hex string
    default java.lang.String toHexByBase64​(java.lang.String base64)
    to hex string
    input base64 string -> (en/de)crypt -> output hex string
    default java.lang.String toHexByHex​(java.lang.String hex)
    to hex string
    input hex string -> (en/de)crypt -> output hex string
  • Method Details

    • encrypt

      static SimpleCrypt encrypt​(java.lang.String transformation, byte[] key, byte[] iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException
      encrypt
      Parameters:
      transformation - ex) AES/CBC/PKCS5Padding
      key - key
      iv - iv
      Returns:
      Throws:
      java.security.InvalidKeyException
      java.security.InvalidAlgorithmParameterException
      java.security.NoSuchAlgorithmException
      javax.crypto.NoSuchPaddingException
    • decrypt

      static SimpleCrypt decrypt​(java.lang.String transformation, byte[] key, byte[] iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException
      decrypt
      Parameters:
      transformation - ex) AES/CBC/PKCS5Padding
      key - key
      iv - iv
      Returns:
      Throws:
      java.security.InvalidKeyException
      java.security.InvalidAlgorithmParameterException
      java.security.NoSuchAlgorithmException
      javax.crypto.NoSuchPaddingException
    • to

      void to​(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
      input -> (en/de)crypt -> output
      Parameters:
      is -
      os -
      Throws:
      java.io.IOException
    • to

      void to​(java.io.File in, java.io.File out, boolean overwrite) throws java.io.IOException
      input file -> (en/de)crypt -> output file
      Parameters:
      in -
      out -
      overwrite - the exist file
      Throws:
      java.io.IOException
    • toBytes

      byte[] toBytes​(byte[] data, int offset, int length) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to byte
      input bytes -> (en/de)crypt -> output bytes
      Parameters:
      data -
      offset -
      length -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toBytes

      byte[] toBytes​(byte[] data) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to byte
      input bytes -> (en/de)crypt -> output bytes
      Parameters:
      data -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toBytesByHex

      default byte[] toBytesByHex​(java.lang.String hex) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to byte
      input hex string -> (en/de)crypt -> output bytes
      Parameters:
      hex -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toBytesByBase64

      default byte[] toBytesByBase64​(java.lang.String base64) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to byte
      input base64 string -> (en/de)crypt -> output bytes
      Parameters:
      base64 -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toHex

      default java.lang.String toHex​(byte[] data, int offset, int length) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to hex string
      input bytes -> (en/de)crypt -> output hex string
      Parameters:
      data -
      offset -
      length -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toHex

      default java.lang.String toHex​(byte[] data) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to hex string
      input bytes -> (en/de)crypt -> output hex string
      Parameters:
      data -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toHexByHex

      default java.lang.String toHexByHex​(java.lang.String hex) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to hex string
      input hex string -> (en/de)crypt -> output hex string
      Parameters:
      hex -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toHexByBase64

      default java.lang.String toHexByBase64​(java.lang.String base64) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to hex string
      input base64 string -> (en/de)crypt -> output hex string
      Parameters:
      base64 -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toBase64

      default java.lang.String toBase64​(byte[] data, int offset, int length) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to base64 string
      input bytes -> (en/de)crypt -> output base64 string
      Parameters:
      data -
      offset -
      length -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toBase64

      default java.lang.String toBase64​(byte[] data) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to base64 string
      input bytes -> (en/de)crypt -> output base64 string
      Parameters:
      data -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toBase64ByHex

      default java.lang.String toBase64ByHex​(java.lang.String hex) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to base64 string
      input hex string -> (en/de)crypt -> output base64 string
      Parameters:
      hex -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException
    • toBase64ByBase64

      default java.lang.String toBase64ByBase64​(java.lang.String base64) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
      to base64 string
      input base64 string -> (en/de)crypt -> output base64 string
      Parameters:
      base64 -
      Returns:
      Throws:
      javax.crypto.IllegalBlockSizeException
      javax.crypto.BadPaddingException