-
Notifications
You must be signed in to change notification settings - Fork 6
CryptoEncryption Methods
Methods to encrypt / decrypt data with different symmetric ciphers. All ciphers use CBC mode with PKCS5 padding.
AES Decryption. Returns original data Base64 encoded.
String
CryptoEncryption.aesDecrypt(String encryptedB64, String secretB64, String ivB64)
Name | Type | Description |
---|---|---|
encryptedB64 | String | Data to decrypt Base64 encoded. |
secretB64 | String | Encryption secret Base64 encoded. For AES 128 this should be 128 bits (16 bytes) long. For AES256 this should be 256 bits (32 bytes) long. |
ivB64 | String | Initialization vector Base64 encoded. 16 bytes long. |
AES Encryption. Returns encrypted data Base64 encoded.
String
CryptoEncryption.aesEncrypt(String dataB64, String secretB64, String ivB64)
Name | Type | Description |
---|---|---|
dataB64 | String | Data to encrypt Base64 encoded. |
secretB64 | String | Encryption secret Base64 encoded. For AES128 this should be 128 bits (16 bytes) long. For AES256 this should be 256 bits (32 bytes) long. |
ivB64 | String | Initialization vector Base64 encoded. 16 bytes long. |
Returns a number of random bytes Base64 encoded.
Useful for creating initialization vectors or random keys.
A new self-seeding, non-blocking, Java SecureRandom number generator is created per method call.
String
CryptoEncryption.generateRandomBytes(Number numberOfBytes)
Name | Type | Description |
---|---|---|
numberOfBytes | Number | Number of random bytes to return. |
Returns 16 random bytes Base64 encoded suitable for an AES initialization vector.
A new self-seeding, non-blocking, Java SecureRandom number generator is created per method call.
String
CryptoEncryption.generateRandomIv()
Name | Type | Description |
---|---|---|
<none> |
3DES (EDE) Decryption. Returns original data Base64 encoded.
String
CryptoEncryption.tripleDesDecrypt(String encryptedB64, String secretB64, String ivB64)
Name | Type | Description |
---|---|---|
encryptedB64 | String | Data to decrypt Base64 encoded. |
secretB64 | String | Encryption secret Base64 encoded. 192 bits (24 bytes) long. If longer, only the first 24 bytes will be used. |
ivB64 | String | Initialization vector Base64 encoded. 8 bytes long. |
3DES (EDE) Encryption. Returns encrypted data Base64 encoded.
String
CryptoEncryption.tripleDesEncrypt(String dataB64, String secretB64, String ivB64)
Name | Type | Description |
---|---|---|
dataB64 | String | Data to encrypt Base64 encoded. |
secretB64 | String | Encryption secret Base64 encoded. 192 bits (24 bytes) long. If longer, only the first 24 bytes will be used. |
ivB64 | String | Initialization vector Base64 encoded. 8 bytes long. |