Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * =============================================================================
   *   Copyright (c) 2007, The JASYPT team (
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
  *   Unless required by applicable law or agreed to in writing, software
  *   distributed under the License is distributed on an "AS IS" BASIS,
  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  * =============================================================================
 package org.jasypt.util.text;

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

This class internally holds a org.jasypt.encryption.pbe.StandardPBEStringEncryptor configured this way:

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

The required steps to use it are:

  1. Create an instance (using new).
  2. Set a password (using setPassword(java.lang.String)).
  3. Perform the desired encrypt(java.lang.String) or decrypt(java.lang.String) operations.

To use this class, you may need to download and install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.

This class is thread-safe.

Daniel Fernández Garrido
1.2 (class existed in org.jasypt.util package since 1.0)
 public final class StrongTextEncryptor implements TextEncryptor {
     // The internal encryptor 
     private StandardPBEStringEncryptor encryptor = null;

Creates a new instance of StrongTextEncryptor.
     public StrongTextEncryptor() {
         this. = new StandardPBEStringEncryptor();

Sets a password.

password the password to be set.
     public void setPassword(String password) {

Encrypts a message.

message the message to be encrypted.
See also:
     public String encrypt(String message) {
         return .encrypt(message);

Decrypts a message.

encryptedMessage the message to be decrypted.
See also:
    public String decrypt(String encryptedMessage) {
        return .decrypt(encryptedMessage);
New to GrepCode? Check out our FAQ X