Package rs.baselib.crypto
Class Decrypter
java.lang.Object
rs.baselib.crypto.Decrypter
The class for decrypting strings.
- Author:
- ralph
-
Constructor Summary
ConstructorDescriptionDecrypter
(byte[] bytephrase, byte[] salt, int iterationCount) Constructor from bytephrase, salt and iteration spec.Decrypter
(char[] passPhrase) Constructor from passphrase.Decrypter
(char[] passPhrase, byte[] salt) Constructor from passphrase.Constructor from passphrase.Constructor from passphrase.Constructor from passphrase, salt and iteration spec.Constructor from secret key.Constructor from secret key.Decrypter
(Key key, String algorithm, AlgorithmParameterSpec paramSpec) Constructor from secret key.Constructor from secret key. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
decrypt
(byte[] bytes) Decrypt a byte arrayTakes a single string as an argument and returns an decrypted version of that string.Returns the algorithm.Returns the algorithmParameterSpec.
-
Constructor Details
-
Decrypter
Constructor from secret key.- Parameters:
dCipher
- the cipher to be used
-
Decrypter
Constructor from secret key.- Parameters:
key
- the secret key to be usedalgorithm
- algorithm (key's algorithm will be used if NULL)- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
public Decrypter(Key key, String algorithm, AlgorithmParameterSpec paramSpec) throws DecryptionException Constructor from secret key.- Parameters:
key
- the secret key to be usedalgorithm
- algorithm (key's algorithm will be used if NULL)paramSpec
- parameters to the decrypting algorithm (will be generated if NULL)- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
public Decrypter(Key key, String algorithm, byte[] salt, int iterationCount) throws DecryptionException Constructor from secret key.- Parameters:
key
- the secret key to be usedalgorithm
- algorithm (key's algorithm will be used if NULL)salt
- salt to be usediterationCount
- number of iterations for decryption- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
Constructor from bytephrase, salt and iteration spec.- Parameters:
bytephrase
- bytephrase to be usedsalt
- salt to be usediterationCount
- number of iterations for decryption- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
Constructor from passphrase.- Parameters:
passPhrase
- passphrase to be used- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
Constructor from passphrase.- Parameters:
passPhrase
- passphrase to be usedsalt
- salt to be used- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
Constructor from passphrase.- Parameters:
passPhrase
- passphrase to be used- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
Constructor from passphrase.- Parameters:
passPhrase
- passphrase to be usedsalt
- salt to be used- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
Decrypter
Constructor from passphrase, salt and iteration spec.- Parameters:
passPhrase
- passphrase to be usedsalt
- salt to be usediterationCount
- number of iterations for decryption- Throws:
DecryptionException
- when decrypting algorithm cannot be generated
-
-
Method Details
-
getAlgorithm
Returns the algorithm.- Returns:
- the algorithm
-
getAlgorithmParameterSpec
Returns the algorithmParameterSpec.- Returns:
- the algorithmParameterSpec
-
decrypt
Takes a single string as an argument and returns an decrypted version of that string.- Parameters:
str
- string to be decrypted- Returns:
string
decrypted version of the provided String- Throws:
DecryptionException
- when decrypting fails
-
decrypt
Decrypt a byte array- Parameters:
bytes
- bytes to be decrypted- Returns:
byte
decrypted version of the provided array- Throws:
DecryptionException
- when decrypting fails
-