Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * =============================================================================
   * 
   *   Copyright (c) 2007, The JASYPT team (http://www.jasypt.org)
   * 
   *   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
   * 
  *       http://www.apache.org/licenses/LICENSE-2.0
  * 
  *   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.numeric;
 
 

Utility class for easily performing normal-strength encryption of BigDecimal objects.

This class internally holds a org.jasypt.encryption.pbe.StandardPBEBigDecimalEncryptor 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(java.lang.String)).
  3. Perform the desired encrypt(java.math.BigDecimal) or decrypt(java.math.BigDecimal) operations.

This class is thread-safe.

Author(s):
Daniel Fernández Garrido
Since:
1.2
 
 public class BasicDecimalNumberEncryptor implements DecimalNumberEncryptor {
 
 
     // The internal encryptor 
     private StandardPBEBigDecimalEncryptor encryptor = null;
    
    
    
Creates a new instance of BasicDecimalNumberEncryptor.
 
     public BasicDecimalNumberEncryptor() {
         super();
         this. = new StandardPBEBigDecimalEncryptor();
         this..setAlgorithm("PBEWithMD5AndDES");
     }

    
    
Sets a password.

Parameters:
password the password to be set.
 
     public void setPassword(String password) {
         .setPassword(password);
     }


    
Encrypts a number

 
     public BigDecimal encrypt(BigDecimal number) {
         return .encrypt(number);
     }
    
    
    
Decrypts a number.

Parameters:
encryptedNumber the number to be decrypted.
See also:
org.jasypt.encryption.pbe.StandardPBEBigDecimalEncryptor.decrypt(java.math.BigDecimal)
    public BigDecimal decrypt(BigDecimal encryptedNumber) {
        return .decrypt(encryptedNumber);
    }
New to GrepCode? Check out our FAQ X