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 array
    java.lang.String decrypt​(java.lang.String str)
    Takes a single string as an argument and returns an decrypted version of that string.
    java.lang.String getAlgorithm()
    Returns the algorithm.
    java.security.spec.AlgorithmParameterSpec getAlgorithmParameterSpec()
    Returns the algorithmParameterSpec.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Decrypter

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

      public Decrypter​(java.security.Key key, java.lang.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​(java.security.Key key, java.lang.String algorithm, java.security.spec.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​(java.security.Key key, java.lang.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​(java.lang.String passPhrase) throws DecryptionException
      Constructor from passphrase.
      Parameters:
      passPhrase - passphrase to be used
      Throws:
      DecryptionException - when decrypting algorithm cannot be generated
    • Decrypter

      public Decrypter​(java.lang.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​(java.lang.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 java.lang.String getAlgorithm()
      Returns the algorithm.
      Returns:
      the algorithm
    • getAlgorithmParameterSpec

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

      public java.lang.String decrypt​(java.lang.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