Package me.saro.commons.crypt
Interface Crypt
-
public interface CryptCrypt thread-safe- Since:
- 3.0
- Author:
- PARK Yong Seo
-
-
Method Summary
Modifier and Type Method Description static Cryptdecrypt(java.lang.String transformation, byte[] key, byte[] iv)decryptstatic Cryptencrypt(java.lang.String transformation, byte[] key, byte[] iv)encryptvoidto(java.io.File in, java.io.File out, boolean overwrite)input file -> (en/de)crypt -> output filevoidto(java.io.InputStream is, java.io.OutputStream os)input -> (en/de)crypt -> outputdefault java.lang.StringtoBase64(byte[] data)to base64 string
input bytes -> (en/de)crypt -> output base64 stringdefault java.lang.StringtoBase64(byte[] data, int offset, int length)to base64 string
input bytes -> (en/de)crypt -> output base64 stringdefault java.lang.StringtoBase64ByBase64(java.lang.String base64)to base64 string
input base64 string -> (en/de)crypt -> output base64 stringdefault java.lang.StringtoBase64ByHex(java.lang.String hex)to base64 string
input hex string -> (en/de)crypt -> output base64 stringbyte[]toBytes(byte[] data)to byte
input bytes -> (en/de)crypt -> output bytesbyte[]toBytes(byte[] data, int offset, int length)to byte
input bytes -> (en/de)crypt -> output bytesdefault byte[]toBytesByBase64(java.lang.String base64)to byte
input base64 string -> (en/de)crypt -> output bytesdefault byte[]toBytesByHex(java.lang.String hex)to byte
input hex string -> (en/de)crypt -> output bytesdefault java.lang.StringtoHex(byte[] data)to hex string
input bytes -> (en/de)crypt -> output hex stringdefault java.lang.StringtoHex(byte[] data, int offset, int length)to hex string
input bytes -> (en/de)crypt -> output hex stringdefault java.lang.StringtoHexByBase64(java.lang.String base64)to hex string
input base64 string -> (en/de)crypt -> output hex stringdefault java.lang.StringtoHexByHex(java.lang.String hex)to hex string
input hex string -> (en/de)crypt -> output hex string
-
-
-
Method Detail
-
encrypt
static Crypt 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/PKCS5Paddingkey- keyiv- iv- Returns:
- Throws:
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingException
-
decrypt
static Crypt 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/PKCS5Paddingkey- keyiv- iv- Returns:
- Throws:
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingException
-
to
void to(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOExceptioninput -> (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.IOExceptioninput 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.BadPaddingExceptionto byte
input bytes -> (en/de)crypt -> output bytes- Parameters:
data-offset-length-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toBytes
byte[] toBytes(byte[] data) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto byte
input bytes -> (en/de)crypt -> output bytes- Parameters:
data-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toBytesByHex
default byte[] toBytesByHex(java.lang.String hex) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto byte
input hex string -> (en/de)crypt -> output bytes- Parameters:
hex-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toBytesByBase64
default byte[] toBytesByBase64(java.lang.String base64) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto byte
input base64 string -> (en/de)crypt -> output bytes- Parameters:
base64-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toHex
default java.lang.String toHex(byte[] data, int offset, int length) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto hex string
input bytes -> (en/de)crypt -> output hex string- Parameters:
data-offset-length-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toHex
default java.lang.String toHex(byte[] data) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto hex string
input bytes -> (en/de)crypt -> output hex string- Parameters:
data-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toHexByHex
default java.lang.String toHexByHex(java.lang.String hex) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto hex string
input hex string -> (en/de)crypt -> output hex string- Parameters:
hex-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toHexByBase64
default java.lang.String toHexByBase64(java.lang.String base64) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto hex string
input base64 string -> (en/de)crypt -> output hex string- Parameters:
base64-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toBase64
default java.lang.String toBase64(byte[] data, int offset, int length) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto base64 string
input bytes -> (en/de)crypt -> output base64 string- Parameters:
data-offset-length-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toBase64
default java.lang.String toBase64(byte[] data) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto base64 string
input bytes -> (en/de)crypt -> output base64 string- Parameters:
data-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toBase64ByHex
default java.lang.String toBase64ByHex(java.lang.String hex) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto base64 string
input hex string -> (en/de)crypt -> output base64 string- Parameters:
hex-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
toBase64ByBase64
default java.lang.String toBase64ByBase64(java.lang.String base64) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingExceptionto base64 string
input base64 string -> (en/de)crypt -> output base64 string- Parameters:
base64-- Returns:
- Throws:
javax.crypto.IllegalBlockSizeExceptionjavax.crypto.BadPaddingException
-
-