Class MDfromHTMLCrypto


  • public class MDfromHTMLCrypto
    extends Object
    Utility to mask / unmask text. While there is a well defined key used for masking, a different key can be set as either an environment variable or passed as a system property (e.g., -Dname=value on Java command line) using the name defined by MDfromHTMLMasker.ENV_MASKER_KEY
    • Field Detail

      • SALT

        public static final byte[] SALT
    • Constructor Detail

      • MDfromHTMLCrypto

        public MDfromHTMLCrypto()
    • Method Detail

      • decrypt

        public static String decrypt​(String text,
                                     char[] key,
                                     byte[] salt)
                              throws Exception
        Unmasks the text using the salt and key
        Parameters:
        text - string to be masked
        key - character phrase used to mask the text
        salt - bytes used to initialize the cryptographic environment
        Returns:
        unmasked version of the masked text
        Throws:
        Exception - if there is a problem with the cryptographic environment
      • decrypt

        public static String decrypt​(String text,
                                     String key)
                              throws Exception
        Unmasks the text using the key and system supplied cryptographic initialization bytes
        Parameters:
        text - string to be unmasked
        key - character phrase used to mask the text
        Returns:
        unmasked version of the masked text
        Throws:
        Exception - if there is a problem with the cryptographic environment
      • encrypt

        public static String encrypt​(String text)
                              throws Exception
        Masks the supplied text
        Parameters:
        text - string to be masked
        Returns:
        masked version of the text
        Throws:
        Exception - if there is a problem with the cryptographic environment
      • encrypt

        public static String encrypt​(String text,
                                     char[] key,
                                     byte[] salt)
                              throws Exception
        Masks the supplied text using the key and salt bytes
        Parameters:
        text - string to be masked
        key - character phrase used to mask the text
        salt - bytes used to initialize the cryptographic environment
        Returns:
        masked version of the text
        Throws:
        Exception - if there is a problem with the cryptographic environment