crypto.createSecretKey(options)
Method Description |
Creates a new crypto.SecretKey object. This method can take a GUID or the script ID of a secret stored at Setup > Company > API Secrets. Use Form.addCredentialField(options) to generate a GUID value. For more information about API Secrets, see Secrets Management.
Note:
When using the crypto.SecretKey object for an AES algorithm, the length of the text (secret key) that is used to generate the GUID must be 16, 24, or 32 characters. |
Returns |
A crypto.SecretKey object |
Supported Script Types |
Server scripts For additional information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string |
required if |
A GUID used to generate a secret key. The GUID can resolve to either data or metadata. You can create a GUID using Form.addCredentialField(options). This is only required if a secret is not provided. You cannot use the |
2015.2 |
|
string |
required if |
The script ID of the secret used for authentication. You can store secrets at Setup > Company > API Secrets. For more information, see Secrets Management. This is only required if GUID is not provided. You cannot use the |
2021.1 |
|
enum |
optional |
Specifies the encoding for the SecureKey. Use the encode.Encoding enum to set the value. The default value is |
2015.2 |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/crypto Module Script Samples.
//Add additional code
...
var secretKey = crypto.createSecretKey({
encoding: encode.Encoding.UTF_8,
guid: '284CFB2D225B1D76FB94D150207E49DF'
});
...
//Add additional code