Package org.jasypt.util.binary
Class BasicBinaryEncryptor
- java.lang.Object
-
- org.jasypt.util.binary.BasicBinaryEncryptor
-
- All Implemented Interfaces:
BinaryEncryptor
public final class BasicBinaryEncryptor extends java.lang.Object implements BinaryEncryptor
Utility class for easily performing normal-strength encryption of binaries (byte arrays).
This class internally holds a
StandardPBEByteEncryptorconfigured this way:- Algorithm: PBEWithMD5AndDES.
- Key obtention iterations: 1000.
The required steps to use it are:
- Create an instance (using new).
- Set a password (using
setPassword(String)orsetPasswordCharArray(char[])). - Perform the desired
encrypt(byte[])ordecrypt(byte[])operations.
This class is thread-safe.
- Since:
- 1.2
-
-
Field Summary
Fields Modifier and Type Field Description private StandardPBEByteEncryptorencryptor
-
Constructor Summary
Constructors Constructor Description BasicBinaryEncryptor()Creates a new instance of BasicBinaryEncryptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]decrypt(byte[] encryptedBinary)Decrypts a byte array.byte[]encrypt(byte[] binary)Encrypts a byte arrayvoidsetPassword(java.lang.String password)Sets a password.voidsetPasswordCharArray(char[] password)Sets a password, as a char[].
-
-
-
Field Detail
-
encryptor
private final StandardPBEByteEncryptor encryptor
-
-
Method Detail
-
setPassword
public void setPassword(java.lang.String password)
Sets a password.- Parameters:
password- the password to be set.
-
setPasswordCharArray
public void setPasswordCharArray(char[] password)
Sets a password, as a char[].- Parameters:
password- the password to be set.- Since:
- 1.8
-
encrypt
public byte[] encrypt(byte[] binary)
Encrypts a byte array- Specified by:
encryptin interfaceBinaryEncryptor- Parameters:
binary- the byte array to be encrypted.- See Also:
StandardPBEByteEncryptor.encrypt(byte[])
-
decrypt
public byte[] decrypt(byte[] encryptedBinary)
Decrypts a byte array.- Specified by:
decryptin interfaceBinaryEncryptor- Parameters:
encryptedBinary- the byte array to be decrypted.- See Also:
StandardPBEByteEncryptor.decrypt(byte[])
-
-