crypto

decrypt(string value, string secret, string transformation, string iv = null)

Decrypts the Base64 value with specified JDK Cipher Transformation string and the provided secret.

The transformation string describes the operation (or set of operations) to be performed on the given input, to produce some output. A transformation always includes the name of a cryptographic algorithm (e.g., AES), and may be followed by a feedback mode and padding scheme. A transformation is of the form: "algorithm/mode/padding" or "algorithm". See Java Cipher for more information. The optional IV parameter sets the initialization vector, if null or not specified, a random one will be generated.

Example:

ds.crypto.decrypt("HrkF1grBXCtATMLxh1gZVA==", "DataSonnet123456", "AES/ECB/PKCS5Padding")
Result
"Hello World"

encrypt(string value, string secret, string transformation, string iv = null)

Encrypts the value with specified JDK Cipher Transformation and the provided secret. Converts the encryption to a readable format with Base64.

The transformation string describes the operation (or set of operations) to be performed on the given input, to produce some output. A transformation always includes the name of a cryptographic algorithm (e.g., AES), and may be followed by a feedback mode and padding scheme. A transformation is of the form: "algorithm/mode/padding" or "algorithm". See Java Cipher for more information. The optional IV parameter sets the initialization vector, if null or not specified, a random one will be generated.

Example:

ds.crypto.encrypt("Hello World", "DataSonnet123456", "AES/ECB/PKCS5Padding")
Result
"HrkF1grBXCtATMLxh1gZVA=="

hash(string value, string algorithm)

Calculates hash of value using one of the supported algorithms. The algorithm must be one of MD2, MD5, SHA-1, SHA-256, SHA-384, SHA-512 The response is a string containing the hash bytes.

Example:

{
    hashValue: ds.crypto.hash("HelloWorld", "MD5")
}
Result
{
    "hashValue": "68e109f0f40ca72a15e05cc22786f8e6"
}

hmac(string value, string secret, string algorithm)

Generates hash-based message authentication code using provided value, secret, and a hash function algorithm. The algorithm must be one of HmacSHA1, HmacSHA256 or HmacSHA512.

Example:

{
    hmacValue: ds.crypto.hmac("HelloWorld", "DataSonnet rules!", "HmacSHA256")
}
Result
{
    "hmacValue": "7854220ef827b07529509f68f391a80bf87fff328dbda140ed582520a1372dc1"
}