Package rs.baselib.crypto
Class Decrypter
java.lang.Object
rs.baselib.crypto.Decrypter
public class Decrypter
extends java.lang.Object
The class for decrypting strings.
- Author:
- ralph
-
Constructor Summary
Constructors Constructor Description Decrypter(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.Decrypter(java.lang.String passPhrase)Constructor from passphrase.Decrypter(java.lang.String passPhrase, byte[] salt)Constructor from passphrase.Decrypter(java.lang.String passPhrase, byte[] salt, int iterationCount)Constructor from passphrase, salt and iteration spec.Decrypter(java.security.Key key, java.lang.String algorithm)Constructor from secret key.Decrypter(java.security.Key key, java.lang.String algorithm, byte[] salt, int iterationCount)Constructor from secret key.Decrypter(java.security.Key key, java.lang.String algorithm, java.security.spec.AlgorithmParameterSpec paramSpec)Constructor from secret key.Decrypter(javax.crypto.Cipher dCipher)Constructor from secret key. -
Method Summary
Modifier and Type Method Description byte[]decrypt(byte[] bytes)Decrypt a byte arrayjava.lang.Stringdecrypt(java.lang.String str)Takes a single string as an argument and returns an decrypted version of that string.java.lang.StringgetAlgorithm()Returns the algorithm.java.security.spec.AlgorithmParameterSpecgetAlgorithmParameterSpec()Returns the algorithmParameterSpec.
-
Constructor Details
-
Decrypter
public Decrypter(javax.crypto.Cipher dCipher)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(java.security.Key key, java.lang.String algorithm, java.security.spec.AlgorithmParameterSpec paramSpec) throws DecryptionExceptionConstructor 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(java.security.Key key, java.lang.String algorithm, byte[] salt, int iterationCount) throws DecryptionExceptionConstructor 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
public Decrypter(java.lang.String passPhrase, byte[] salt, int iterationCount) throws DecryptionExceptionConstructor 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
public java.lang.String getAlgorithm()Returns the algorithm.- Returns:
- the algorithm
-
getAlgorithmParameterSpec
public java.security.spec.AlgorithmParameterSpec 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:
stringdecrypted version of the provided String- Throws:
DecryptionException- when decrypting fails
-
decrypt
Decrypt a byte array- Parameters:
bytes- bytes to be decrypted- Returns:
bytedecrypted version of the provided array- Throws:
DecryptionException- when decrypting fails
-