play.libs
Class Crypto

java.lang.Object
  extended by play.libs.Crypto

public class Crypto
extends java.lang.Object

Crypto utils


Constructor Summary
Crypto()
           
 
Method Summary
static java.lang.String decryptAES(java.lang.String value)
          Decrypt a String with the AES encryption standard using the application secret
static java.lang.String decryptAES(java.lang.String value, java.lang.String privateKey)
          Decrypt a String with the AES encryption standard.
static java.lang.String encryptAES(java.lang.String value)
          Encrypt a String with the AES encryption standard using the application secret
static java.lang.String encryptAES(java.lang.String value, java.lang.String privateKey)
          Encrypt a String with the AES encryption standard.
static java.lang.String passwordHash(java.lang.String input)
          Create an MD5 password hash
static java.lang.String sign(java.lang.String message)
          Sign a message using the application secret key (HMAC-SHA1)
static java.lang.String sign(java.lang.String message, byte[] key)
          Sign a message with a key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Crypto

public Crypto()
Method Detail

sign

public static java.lang.String sign(java.lang.String message)
Sign a message using the application secret key (HMAC-SHA1)


sign

public static java.lang.String sign(java.lang.String message,
                                    byte[] key)
Sign a message with a key

Parameters:
message - The message to sign
key - The key to use
Returns:
The signed message (in hexadecimal)
Throws:
java.lang.Exception

passwordHash

public static java.lang.String passwordHash(java.lang.String input)
Create an MD5 password hash

Parameters:
input - The password
Returns:
The password hash

encryptAES

public static java.lang.String encryptAES(java.lang.String value)
Encrypt a String with the AES encryption standard using the application secret

Parameters:
value - The String to encrypt
Returns:
An hexadecimal encrypted string

encryptAES

public static java.lang.String encryptAES(java.lang.String value,
                                          java.lang.String privateKey)
Encrypt a String with the AES encryption standard. Private key must have a length of 16 bytes

Parameters:
value - The String to encrypt
privateKey - The key used to encrypt
Returns:
An hexadecimal encrypted string

decryptAES

public static java.lang.String decryptAES(java.lang.String value)
Decrypt a String with the AES encryption standard using the application secret

Parameters:
value - An hexadecimal encrypted string
Returns:
The decrypted String

decryptAES

public static java.lang.String decryptAES(java.lang.String value,
                                          java.lang.String privateKey)
Decrypt a String with the AES encryption standard. Private key must have a length of 16 bytes

Parameters:
value - An hexadecimal encrypted string
privateKey - The key used to encrypt
Returns:
The decrypted String


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly