org.apache.turbine.services.crypto
Interface CryptoAlgorithm

All Known Implementing Classes:
ClearCrypt, JavaCrypt, OldJavaCrypt, UnixCrypt

public interface CryptoAlgorithm

This interface describes the various Crypto Algorithms that are handed out by the Crypto Service.

Version:
$Id: CryptoAlgorithm.java 534527 2007-05-02 16:10:59Z tv $
Author:
Henning P. Schmiedehausen

Method Summary
 java.lang.String encrypt(java.lang.String value)
          Performs the actual encryption.
 void setCipher(java.lang.String cipher)
          Algorithms that perform multiple ciphers get told with setCipher, which cipher to use.
 void setSeed(java.lang.String salt)
          Allows the user to set a salt value whenever the algorithm is used.
 

Method Detail

setSeed

public void setSeed(java.lang.String salt)
Allows the user to set a salt value whenever the algorithm is used. Setting a new salt should invalidate all internal state of this object.

Algorithms that do not use a salt are allowed to ignore this parameter.

Algorithms must be able to deal with the null value as salt. They should treat it as "use a random salt".

Parameters:
salt - The salt value

encrypt

public java.lang.String encrypt(java.lang.String value)
                         throws java.lang.Exception
Performs the actual encryption.

Parameters:
value - The value to be encrypted
Returns:
The encrypted value
Throws:
java.lang.Exception - various errors from the underlying ciphers. The caller should catch them and report accordingly.

setCipher

public void setCipher(java.lang.String cipher)
Algorithms that perform multiple ciphers get told with setCipher, which cipher to use. This should be called before any other method call. If called after any call to encrypt or setSeed, the CryptoAlgorithm may choose to ignore this or to reset and use the new cipher. If any other call is used before this, the algorithm should use a default cipher and not throw an error.

Parameters:
cipher - The cipher to use.


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.