|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.kernel.security.Crypto
Provides cryptographic functions and stores the server's secret key.
Field Summary | |
static String |
CHARACTER_ENCODING
|
static String |
versionId
|
Constructor Summary | |
Crypto()
|
Method Summary | |
static String |
decrypt(String encrypted,
char[] password)
Decrypts a string with a key derived from a password. |
static String |
encrypt(String decrypted,
char[] password)
Encrypts a string with a key derived from a password. |
static SecureRandom |
getRandom()
Returns a secure random number generator. |
static void |
main(String[] args)
Benchmarks password-based encryption and decryption. |
static MessageDigest |
newDigester()
Creates a new message digest (hash) calculator. |
static javax.crypto.Mac |
newMac()
Creates a new Message Authentication Code (MAC) calculator that uses the server's secret key. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
public static final String CHARACTER_ENCODING
Constructor Detail |
public Crypto()
Method Detail |
public static javax.crypto.Mac newMac() throws GeneralSecurityException
Mac
object.
GeneralSecurityException
- if an error occurs.public static MessageDigest newDigester() throws GeneralSecurityException
MessageDigest
object.
GeneralSecurityException
- if an error occurs.public static SecureRandom getRandom() throws GeneralSecurityException
SecureRandom
number generator.
GeneralSecurityException
- if an error occurs.public static String encrypt(String decrypted, char[] password) throws GeneralSecurityException
BASE64Encode(salt) + ":" +
BASE64Encode(encrypt(UTF8Encode(cleartext.length() + ":" +
cleartext)))
.
decrypted
- the string to encryptpassword
- the password from which to create an encryption key
GeneralSecurityException
- if encryption fails.public static String decrypt(String encrypted, char[] password) throws GeneralSecurityException
encrypted
- the string to decryptpassword
- the password from which to create an decryption key
IllegalArgumentException
- if the given string is not legal
output of encrypt().
InvalidKeyException
- if the decrypted text does not pass
validation.
GeneralSecurityException
- if decryption fails otherwise.public static void main(String[] args) throws GeneralSecurityException
GeneralSecurityException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |