Package com.mdfromhtml.core
Class MDfromHTMLCrypto
- java.lang.Object
-
- com.mdfromhtml.core.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 byMDfromHTMLMasker.ENV_MASKER_KEY
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]SALT
-
Constructor Summary
Constructors Constructor Description MDfromHTMLCrypto()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringdecrypt(String text, char[] key, byte[] salt)Unmasks the text using the salt and keystatic Stringdecrypt(String text, String key)Unmasks the text using the key and system supplied cryptographic initialization bytesstatic Stringencrypt(String text)Masks the supplied textstatic Stringencrypt(String text, char[] key, byte[] salt)Masks the supplied text using the key and salt bytesstatic voidmain(String[] args)
-
-
-
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 maskedkey- character phrase used to mask the textsalt- 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 unmaskedkey- 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 maskedkey- character phrase used to mask the textsalt- bytes used to initialize the cryptographic environment- Returns:
- masked version of the text
- Throws:
Exception- if there is a problem with the cryptographic environment
-
-