SecureString.hmac(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Creates an hmac for a https.SecureString using a specified hash algorithm and secret key. You can optionally specify the encoding used to convert the SecureString content to and the encoding used to encode the result as a string. Use https.HashAlg to set the hash algorithm.

Returns

https.SecureString

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/https Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.algorithm

string

required

The hash algorithm. Use values from the https.HashAlg enum.

options.key

crypto.SecretKey

required

A key returned from https.createSecretKey(options).

options.contentEncoding

string

optional

Encoding used to convert/decode the current string content into binary data for hmac processing. Use values from the https.Encoding enum.

Defaults to current internal encoding of the SecureString. Although a default is provided, we highly encourage the use of this parameter for the most secure and correct encoding.

options.resultEncoding

string

optional

Encoding used to encode the binary result as a string. Use values from the https.Encoding enum.

Defaults to HEX when options.contentEncoding is specified, otherwise defaults to current internal encoding of the SecureString. Although a default is provided, we highly encourage the use of this parameter for the most secure and correct encoding.

Errors

Error Code

Thrown If

FAILED_TO_CONVERT_BINARY_DATA_TO_UTF_8

An invalid attempt was made to encode the binary result to UTF-8 string.

FAILED_TO_DECODE_STRING_ENCODED_BINARY_DATA_USING_1_ENCODING

The content of the SecureString is not a valid encoded string according to the options.contentEncoding parameter value.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/https Module Script Samples.

          // Add additional code 
...
var secureString1 = https.createSecureString({
    input: "myString1"
});
var hmacString1 = secureString1.hmac({
    algorithm: https.HashAlg.SHA256,
    key: mySecretKey
});
...
// Add additional code 

        

Related Topics

https.SecureString
N/https Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices