Package play.libs
Class Crypto
- java.lang.Object
-
- play.libs.Crypto
-
public class Crypto extends java.lang.Object
Cryptography utils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Crypto.HashType
Define a hash type enumeration for strong-typing
-
Constructor Summary
Constructors Constructor Description Crypto()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
decryptAES(java.lang.String value)
Decrypt a String with the AES encryption standard using the application secretstatic 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 secretstatic 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 algorithmstatic java.lang.String
passwordHash(java.lang.String input, Crypto.HashType hashType)
Create a password hash using specific hashing algorithmstatic 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
-
-
-
Method Detail
-
sign
public static java.lang.String sign(java.lang.String message)
Sign a message using the application secret key (HMAC-SHA1)- Parameters:
message
- the message to sign- Returns:
- The signed message
-
sign
public static java.lang.String sign(java.lang.String message, byte[] key)
Sign a message with a key- Parameters:
message
- The message to signkey
- The key to use- Returns:
- The signed message (in hexadecimal)
-
passwordHash
public static java.lang.String passwordHash(java.lang.String input)
Create a password hash using the default hashing algorithm- Parameters:
input
- The password- Returns:
- 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- Parameters:
input
- The passwordhashType
- The hashing algorithm- 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 encryptprivateKey
- 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 stringprivateKey
- The key used to encrypt- Returns:
- The decrypted String
-
-