play.libs
类 Crypto

java.lang.Object
  继承者 play.libs.Crypto

public class Crypto
extends java.lang.Object

Cryptography utils


嵌套类摘要
static class Crypto.HashType
          Define a hash type enumeration for strong-typing
 
构造方法摘要
Crypto()
           
 
方法摘要
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 a password hash using the default hashing algorithm
static java.lang.String passwordHash(java.lang.String input, Crypto.HashType hashType)
          Create a password hash using specific hashing algorithm
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
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

Crypto

public Crypto()
方法详细信息

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

参数:
message - The message to sign
key - The key to use
返回:
The signed message (in hexadecimal)
抛出:
java.lang.Exception

passwordHash

public static java.lang.String passwordHash(java.lang.String input)
Create a password hash using the default hashing algorithm

参数:
input - The password
返回:
The password hash

passwordHash

public static java.lang.String passwordHash(java.lang.String input,
                                            Crypto.HashType hashType)
Create a password hash using specific hashing algorithm

参数:
input - The password
hashType - The hashing algorithm
返回:
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

参数:
value - The String to encrypt
返回:
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

参数:
value - The String to encrypt
privateKey - The key used to encrypt
返回:
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

参数:
value - An hexadecimal encrypted string
返回:
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

参数:
value - An hexadecimal encrypted string
privateKey - The key used to encrypt
返回:
The decrypted String


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