Class BasicTextEncryptor

  • All Implemented Interfaces:
    TextEncryptor

    public final class BasicTextEncryptor
    extends Object
    implements TextEncryptor

    Utility class for easily performing normal-strength encryption of texts.

    This class internally holds a StandardPBEStringEncryptor configured this way:

    • Algorithm: PBEWithMD5AndDES.
    • Key obtention iterations: 1000.

    The required steps to use it are:

    1. Create an instance (using new).
    2. Set a password (using setPassword(String) or setPasswordCharArray(char[])).
    3. Perform the desired encrypt(String) or decrypt(String) operations.

    This class is thread-safe.

    Since:
    1.2 (class existed as org.jasypt.util.TextEncryptor since 1.0)
    Author:
    Daniel Fernández
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicTextEncryptor()
      Creates a new instance of BasicTextEncryptor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String decrypt​(String encryptedMessage)
      Decrypts a message.
      String encrypt​(String message)
      Encrypts a message.
      void setPassword​(String password)
      Sets a password.
      void setPasswordCharArray​(char[] password)
      Sets a password, as a char[]
      • Methods inherited from class java.lang.Object

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

      • BasicTextEncryptor

        public BasicTextEncryptor()
        Creates a new instance of BasicTextEncryptor.
    • Method Detail

      • setPassword

        public void setPassword​(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