public class PassphraseCrypto
extends java.lang.Object
http://java.sun.com/developer/technicalArticles/Security/JCE/
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DES
Encrypt algorithm
|
static java.lang.String |
PBE_WITH_MD5_AND_DES
The key format: password-based encrypt with MD5 and DES.
|
static java.lang.String |
UTF8
Encrytp encoding
|
Constructor and Description |
---|
PassphraseCrypto() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decrypt(java.lang.String encrypted,
java.lang.String passPhrase)
Create the key
Decode base64 to get bytes of the secret word
Prepare the parameter to the ciphers
Decrypt
Decode using utf-8
|
static java.lang.String |
encrypt(java.lang.String plain,
java.lang.String passPhrase)
Create the key
Prepare the parameter to the ciphers
Create the ciphers
Encode the string into bytes using utf-8
Encrypt
Encode bytes to base64 to get a string
|
public static final java.lang.String DES
public static final java.lang.String UTF8
public static final java.lang.String PBE_WITH_MD5_AND_DES
PBEKeySpec
,
Constant Field Valuespublic static java.lang.String encrypt(java.lang.String plain, java.lang.String passPhrase) throws java.lang.Exception
plain
- The password to be decrypted.java.lang.Exception
- a generic exception caused during the decrypt process.public static java.lang.String decrypt(java.lang.String encrypted, java.lang.String passPhrase) throws java.lang.Exception
encrypted
- The password to be decrypted.java.lang.Exception
- a generic exception caused during the decrypt process.