Class EncryptionUtility
- java.lang.Object
-
- org.smallmind.nutsnbolts.security.EncryptionUtility
-
public class EncryptionUtility extends Object
-
-
Constructor Summary
Constructors Constructor Description EncryptionUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decrypt(Key key, byte[] toBeDecrypted)static byte[]decrypt(Key key, byte[] toBeDecrypted, AlgorithmParameterSpec algorithmParameterSpec)static byte[]decrypt(Key key, String specificAlgorithm, byte[] toBeDecrypted)static byte[]decrypt(Key key, String specificAlgorithm, byte[] toBeDecrypted, AlgorithmParameterSpec algorithmParameterSpec)static KeydeserializeKey(byte[] keyBytes)static byte[]encrypt(Key key, byte[] toBeEncrypted)static byte[]encrypt(Key key, byte[] toBeEncrypted, AlgorithmParameterSpec algorithmParameterSpec)static byte[]encrypt(Key key, String specificAlgorithm, byte[] toBeEncrypted)static byte[]encrypt(Key key, String specificAlgorithm, byte[] toBeEncrypted, AlgorithmParameterSpec algorithmParameterSpec)static KeygenerateKey(SymmetricAlgorithm algorithm)static KeyPairgenerateKeyPair(AsymmetricAlgorithm algorithm)static byte[]hash(HashAlgorithm algorithm, byte[] toBeHashed)static byte[]hexDecode(byte[] toBeDecoded)static byte[]hexDecode(String toBeDecoded)static StringhexEncode(byte[] bytes)static StringhexEncode(byte[] bytes, int offset, int length)static byte[]serializeKey(Key key)static byte[]sign(HMACSigningAlgorithm algorithm, Key secretKey, byte[] data)static byte[]sign(RSASigningAlgorithm algorithm, PrivateKey privateKey, byte[] data)static booleanverify(RSASigningAlgorithm algorithm, PublicKey publicKey, byte[] data, byte[] signedData)
-
-
-
Method Detail
-
hexEncode
public static String hexEncode(byte[] bytes)
-
hexEncode
public static String hexEncode(byte[] bytes, int offset, int length)
-
hexDecode
public static byte[] hexDecode(String toBeDecoded) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
hexDecode
public static byte[] hexDecode(byte[] toBeDecoded) throws UnsupportedEncodingException- Throws:
UnsupportedEncodingException
-
hash
public static byte[] hash(HashAlgorithm algorithm, byte[] toBeHashed) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
sign
public static byte[] sign(HMACSigningAlgorithm algorithm, Key secretKey, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException
-
sign
public static byte[] sign(RSASigningAlgorithm algorithm, PrivateKey privateKey, byte[] data) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException
-
verify
public static boolean verify(RSASigningAlgorithm algorithm, PublicKey publicKey, byte[] data, byte[] signedData) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException
-
generateKey
public static Key generateKey(SymmetricAlgorithm algorithm) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
generateKeyPair
public static KeyPair generateKeyPair(AsymmetricAlgorithm algorithm) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
serializeKey
public static byte[] serializeKey(Key key) throws IOException
- Throws:
IOException
-
deserializeKey
public static Key deserializeKey(byte[] keyBytes) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
encrypt
public static byte[] encrypt(Key key, byte[] toBeEncrypted) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
encrypt
public static byte[] encrypt(Key key, String specificAlgorithm, byte[] toBeEncrypted) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
encrypt
public static byte[] encrypt(Key key, byte[] toBeEncrypted, AlgorithmParameterSpec algorithmParameterSpec) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
encrypt
public static byte[] encrypt(Key key, String specificAlgorithm, byte[] toBeEncrypted, AlgorithmParameterSpec algorithmParameterSpec) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
decrypt
public static byte[] decrypt(Key key, byte[] toBeDecrypted) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
decrypt
public static byte[] decrypt(Key key, String specificAlgorithm, byte[] toBeDecrypted) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
decrypt
public static byte[] decrypt(Key key, byte[] toBeDecrypted, AlgorithmParameterSpec algorithmParameterSpec) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
decrypt
public static byte[] decrypt(Key key, String specificAlgorithm, byte[] toBeDecrypted, AlgorithmParameterSpec algorithmParameterSpec) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
-
-