|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.dyuproject.util.Cryptography
public final class Cryptography
Encryption and Decryption utility
Field Summary | |
---|---|
static String |
DES
The algorithm used for 8-character secret keys. |
static String |
DESede
The algorithm used for 24-character secret keys. |
Method Summary | |
---|---|
static Cryptography |
create(byte[] secretKey,
String algorithm)
Creates a new instance with the given bytes secretKey and algorithm . |
static Cryptography |
create(String secretKey,
char pad)
Creates a new instance with the given secretKey and the character
pad for padding if the key is not long enough. |
static Cryptography |
create(String secretKey,
String algorithm)
Creates a new instance with the given secretKey and algorithm . |
static Cryptography |
create(String secretKey,
String charset,
String algorithm)
Creates a new instance with the given secretKey , charset
and algorithm . |
static Cryptography |
createDES(String secretKey)
Creates a new instance with the given secretKey . |
static Cryptography |
createDESede(String secretKey)
Creates a new instance with the given secretKey . |
byte[] |
decrypt(byte[] input)
Decrypts the given bytes input . |
String |
decrypt(String input)
Decrypts the given string input with ISO-8859-1 encoding. |
String |
decrypt(String input,
String charset)
Decrypts the given string input with ISO-8859-1 encoding. |
String |
decryptDecode(String input)
Decodes the given string input with base 64 using ISO-8859-1 and
decrypts the decoded string. |
String |
decryptDecode(String input,
String charset)
Decodes the given string input with base 64 using the given charset and
decrypts the decoded string. |
byte[] |
encrypt(byte[] input)
Encrypts the given bytes input . |
String |
encrypt(String input)
Encrypts the given string input with ISO-8859-1 encoding. |
String |
encrypt(String input,
String charset)
Encrypts the given string input encoded with the given charset . |
String |
encryptEncode(String input)
Encrypts the given string input encoded with ISO-8859-1;
The encrypted bytes will then be b64 encoded. |
String |
encryptEncode(String input,
String charset)
Encrypts the given string input encoded with the given charset ;
The encrypted bytes will then be b64 encoded. |
static Cryptography |
generateDESedeRandom()
Creates a new instance with a random secret that is 24 characters long. |
static Cryptography |
generateDESRandom()
Creates a new instance with a random secret that is 8 characters long. |
static Cryptography |
generateRandom(String algorithm)
Creates a new instance with a random secret with the given algorithm . |
Key |
getKey()
Gets the secret key. |
static String |
pad(String secretKey,
char pad)
Returns a string padded with the given character pad if the length is not
equal to 8 or 24. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DES
public static final String DESede
Method Detail |
---|
public static String pad(String secretKey, char pad)
pad
if the length is not
equal to 8 or 24.
public static Cryptography create(String secretKey, char pad) throws Exception
secretKey
and the character
pad
for padding if the key is not long enough.
IllegalArgumentException
- if the secretKey
is more than 24 characters long.
Exception
public static Cryptography createDES(String secretKey) throws Exception
secretKey
.
IllegalArgumentException
- if the secretKey
is not 8 characters long.
Exception
public static Cryptography createDESede(String secretKey) throws Exception
secretKey
.
IllegalArgumentException
- if the secretKey
is not 24 characters long.
Exception
public static Cryptography create(String secretKey, String algorithm) throws Exception
secretKey
and algorithm
.
Exception
public static Cryptography create(String secretKey, String charset, String algorithm) throws Exception
secretKey
, charset
and algorithm
.
Exception
public static Cryptography create(byte[] secretKey, String algorithm) throws Exception
secretKey
and algorithm
.
Exception
public static Cryptography generateDESRandom() throws Exception
Exception
public static Cryptography generateDESedeRandom() throws Exception
Exception
public static Cryptography generateRandom(String algorithm) throws Exception
algorithm
.
Exception
public byte[] encrypt(byte[] input) throws Exception
input
.
Exception
public String encrypt(String input) throws Exception
input
with ISO-8859-1 encoding.
Exception
public String encrypt(String input, String charset) throws Exception
input
encoded with the given charset
.
Exception
public String encryptEncode(String input) throws Exception
input
encoded with ISO-8859-1;
The encrypted bytes will then be b64 encoded.
Exception
public String encryptEncode(String input, String charset) throws Exception
input
encoded with the given charset
;
The encrypted bytes will then be b64 encoded.
Exception
public byte[] decrypt(byte[] input) throws Exception
input
.
Exception
public String decrypt(String input) throws Exception
input
with ISO-8859-1 encoding.
Exception
public String decrypt(String input, String charset) throws Exception
input
with ISO-8859-1 encoding.
Exception
public String decryptDecode(String input) throws Exception
input
with base 64 using ISO-8859-1 and
decrypts the decoded string.
Exception
public String decryptDecode(String input, String charset) throws Exception
input
with base 64 using the given charset
and
decrypts the decoded string.
Exception
public Key getKey()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |