Class MessageDigestCipher

  • All Implemented Interfaces:
    ICipher, ICipherSpi

    public class MessageDigestCipher
    extends AbstractCipher
    Uses a MessageDigest algorithm to encrypt data.

    In this cipher's configuration, the value of algorithm element is used to specify the MessageDigest algorithm; and the provider element may optionally be used to specify the MessageDigest provider.

    Since:
    5.5.0
    Version:
    $Revision: 11180 $ $Date: 2009-12-04 18:13:02 -0200 (Fri, 04 Dec 2009) $
    See Also:
    MessageDigest
    • Constructor Detail

      • MessageDigestCipher

        public MessageDigestCipher()
    • Method Detail

      • getUseURLSafeBase64Variant

        protected boolean getUseURLSafeBase64Variant()
        Description copied from class: AbstractCipher
        Indicates if a URL safe Base64 variant is to be used when encoding bytes to String.

        The default value is true. This method may be overridden to change it.

        Overrides:
        getUseURLSafeBase64Variant in class AbstractCipher
        Returns:
        true if a URL safe variant is to be used, false if the standard Base64 is to be used.
      • getAlgorithm

        protected String getAlgorithm()
        Returns the message digest algorithm to be used.
        Returns:
        the algorithm.
        Since:
        5.5.0
      • setAlgorithm

        protected void setAlgorithm​(String algorithm)
        Sets the message digest algorithm to be used.
        Parameters:
        algorithm - the algorithm.
        Since:
        5.5.0
      • getProvider

        protected String getProvider()
        Returns the message digest provider to be used.
        Returns:
        the provider, or null if the default provider search is to be used.
        Since:
        5.5.0
      • setProvider

        protected void setProvider​(String provider)
        Sets the message digest provider to be used.
        Parameters:
        provider - the provider, or null if the default provider search is to be used.
        Since:
        5.5.0
      • init

        public void init​(Node configuration)
                  throws PortalException
        Description copied from interface: ICipherSpi
        This method is called only once and before any other method are called. This allows the cipher to initialize itself and read any custom configuration.
        Throws:
        PortalException
      • encrypt

        public byte[] encrypt​(byte[] value)
        Description copied from interface: ICipher
        Encrypts an array of bytes.
        Parameters:
        value - the original value.
        Returns:
        the encrypted value.
      • decrypt

        public byte[] decrypt​(byte[] value)
        Description copied from interface: ICipher
        Decrypts an array of bytes.
        Parameters:
        value - the encrypted value.
        Returns:
        the value decrypted.