N/crypto Module

Use N/crypto module to perform hashing, hash-based message authentication (hmac), and symmetrical encryption functions.

When the N/crypto module is used, SuiteScript also loads N/encode Module.

                                   

In This Help Topic

N/crypto Module Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Object

crypto.Cipher

Object

Server scripts

Encapsulates a cipher.

crypto.CipherPayload

Object

Server scripts

Encapsulates a cipher payload.

crypto.Decipher

Object

Server scripts

Encapsulates a decipher.

crypto.Hash

Object

Server scripts

Encapsulates a hash.

crypto.Hmac

Object

Server scripts

Encapsulates an hmac.

crypto.SecretKey

Object

Server scripts

Encapsulates a secret key handle.

Method

crypto.checkPasswordField(options)

boolean

Server scripts

Checks whether a password in a record corresponds to the password entered by the user.

crypto.createCipher(options)

Object

Server scripts

Creates and returns a new crypto.Cipher Object.

crypto.createDecipher(options)

Object

Server scripts

Creates and returns a new crypto.Decipher object.

crypto.createHash(options)

Object

Server scripts

Creates and returns a new crypto.Hash Object.

crypto.createHmac(options)

Object

Server scripts

Creates and returns a new crypto.Hmac Object.

crypto.createSecretKey(options)

Object

Server scripts

Creates and returns a new crypto.SecretKey Object.

Enum

crypto.EncryptionAlg

string (read-only)

Server scripts

Holds the string values for supported encryption algorithms. Use this enum to set the options.algorithm parameter for crypto.createCipher(options).

crypto.HashAlg

string (read-only)

Server scripts

Holds the string values for supported hashing algorithms. Use this enum to set the options.algorithm parameter for crypto.createHash(options) and crypto.createHmac(options).

crypto.Padding

string (read-only)

Server scripts

Holds the string values for supported cipher padding. Use this enum to set the options.padding parameter for crypto.createCipher(options) and crypto.createDecipher(options).

Cipher Object Members

The following members are called on crypto.Cipher.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Cipher.update(options)

void

Server scripts

Updates the clear data with the specified encoding.

Cipher.final(options)

Object

Server scripts

Returns the cipher data.

CipherPayload Object Members

The following members are called on crypto.CipherPayload.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

CipherPayload.ciphertext

string

Server scripts

The result of the ciphering process.

CipherPayload.iv

number

Server scripts

An initialization vector.

Decipher Object Members

The following members are called on crypto.Decipher.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Decipher.final(options)

string

Server scripts

Returns the clear data.

Decipher.update(options)

void

Server scripts

Updates decipher data with the specified encoding.

Hash Object Members

The following members are called on crypto.Hash.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Hash.digest(options)

string

Server scripts

Calculates the digest of the data to be hashed.

Hash.update(options)

void

Server scripts

Updates the clear data with the encoding specified.

Hmac Object Members

The following members are called on crypto.Hmac.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Hmac.digest(options)

string

Server scripts

Gets the computed digest.

Hmac.update(options)

void

Server scripts

Updates the clear data with the encoding specified.

SecretKey Object Members

The following members are called on crypto.SecretKey.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Secretkey.guid

string

Server scripts

The GUID associated with the secret key.

SecretKey.encoding

string

Server scripts

The encoding used for the clear text value of the secret key.

SecretKey.password

string

Server scripts

The script ID of an API secret stored at Setup > Company > API Secrets.

Related Topics

General Notices