encrypt (NotesXSPDocument - JavaScript)

Encrypts a document associated with the XPage context in which the server script is running.

Defined in

NotesXSPDocument

Syntax

encrypt() : void
encrypt(UserID:NotesUserID) : void
Parameter Description
Userid NotesUserID (type). After setting the User id, the document will be encrypted with encryption keys of this user id

Usage

Overview

An encrypted document is not saved until you call save. Only the items for which isEncrypted is true are encrypted. Items for which isEncrypted is false remain visible to any user, even if the user does not have the proper encryption key.

If the EncryptionKeys property is set with one or more named keys, those keys are used to encrypt the document. Any user who has one of the encryption keys can decrypt the document. If there are no encryption keys specified, the document is encrypted with the user's public key, in which case only the user who encrypted the document can decrypt it.

If the program is running on a server, it must have permission to encrypt.

Specifics for XPages encryption

This method is used for encrypting XPages. To encrypt a document with a private key on web or server use the following general coding steps:
  • Fetch the IDVault object
  • Fetch a UserID object out of the IDVault for a particular user with the getUserIDFile method.
  • Get a list of private key names that are available to use with the UserID with the getEncryptionKeys method.
  • Specify which key to use to encrypt the doc with the setEncryptionKeys method.
  • Use the encrypt method to encrypt note with the specified encryption key set with setEncryptionKeys