Class Decrypter

java.lang.Object
rs.baselib.crypto.Decrypter

public class Decrypter extends Object
The class for decrypting strings.
Author:
ralph
  • Constructor Details

    • Decrypter

      public Decrypter(Cipher dCipher)
      Constructor from secret key.
      Parameters:
      dCipher - the cipher to be used
    • Decrypter

      public Decrypter(Key key, String algorithm) throws DecryptionException
      Constructor from secret key.
      Parameters:
      key - the secret key to be used
      algorithm - 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 used
      algorithm - 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 used
      algorithm - algorithm (key's algorithm will be used if NULL)
      salt - salt to be used
      iterationCount - number of iterations for decryption
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
    • Decrypter

      public Decrypter(byte[] bytephrase, byte[] salt, int iterationCount) throws DecryptionException
      Constructor from bytephrase, salt and iteration spec.
      Parameters:
      bytephrase - bytephrase to be used
      salt - salt to be used
      iterationCount - number of iterations for decryption
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
    • Decrypter

      public Decrypter(char[] passPhrase) throws DecryptionException
      Constructor from passphrase.
      Parameters:
      passPhrase - passphrase to be used
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
    • Decrypter

      public Decrypter(char[] passPhrase, byte[] salt) throws DecryptionException
      Constructor from passphrase.
      Parameters:
      passPhrase - passphrase to be used
      salt - salt to be used
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
    • Decrypter

      public Decrypter(String passPhrase) throws DecryptionException
      Constructor from passphrase.
      Parameters:
      passPhrase - passphrase to be used
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
    • Decrypter

      public Decrypter(String passPhrase, byte[] salt) throws DecryptionException
      Constructor from passphrase.
      Parameters:
      passPhrase - passphrase to be used
      salt - salt to be used
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
    • Decrypter

      public Decrypter(String passPhrase, byte[] salt, int iterationCount) throws DecryptionException
      Constructor from passphrase, salt and iteration spec.
      Parameters:
      passPhrase - passphrase to be used
      salt - salt to be used
      iterationCount - number of iterations for decryption
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
  • Method Details

    • getAlgorithm

      public String getAlgorithm()
      Returns the algorithm.
      Returns:
      the algorithm
    • getAlgorithmParameterSpec

      public AlgorithmParameterSpec getAlgorithmParameterSpec()
      Returns the algorithmParameterSpec.
      Returns:
      the algorithmParameterSpec
    • decrypt

      public String decrypt(String str) throws DecryptionException
      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

      public byte[] decrypt(byte[] bytes) throws DecryptionException
      Decrypt a byte array
      Parameters:
      bytes - bytes to be decrypted
      Returns:
      byte decrypted version of the provided array
      Throws:
      DecryptionException - when decrypting fails