MessageData.encrypt(options)

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Creates an encrypted message that is optionally signed.

Returns

pgp.Message

Supported Script Types

Server Scripts

Governance

None

Module

N/pgp Module

Parent Object

pgp.MessageData

Sibling Object Members

MessageData Object Members

Since

2022.2

Parameters

Parameter

Type

Required / Optional

Description

Since

options.encryptionKeys

pgp.Key | pgp.Key[]

Required

One or more keys used to encrypt a message. If a key contains multiple valid encryption (sub)keys, the most recent key added will be used.

2022.2

options.signingKeys

pgp.Key | pgp.Key[]

optional

Zero or more keys used for signing. If a key contains multiple valid signing (sub)keys, the most recent key added will be used. Default value = [].

2022.2

options.compressionAlgorithm

pgp.CompressionAlgorithm

optional

The compression algorithm to use. Default value = CompressionAlgorithm.ZLIB.

2022.2

Errors

Error Code

Thrown If

PGP_NO_ENCRYPTION_KEY_FOUND_IN_KEY_PARAM_1

No valid encryption (sub)key was found in one of the provided keys.

PGP_NO_SIGNING_KEY_FOUND_IN_KEY_PARAM_1

No valid signing (sub)key was found in one of the provided keys.

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/pgp Module Script Samples.

            // Add additional code
...

const data = pgp.createMessageData({ 
   content: "Hello, world!"
});
const message = data.encrypt({ 
   encryptionKeys: keys.alice.pub,
   signingKeys: keys.ours.pri,
});

...
// Add additional code 

          

Related Topics

General Notices