encrypt (NotesDocument - JavaScript™)
Encrypts a document.
Defined in
NotesDocumentSyntax
encrypt() : void
encrypt(UserID:NotesUserID) : void
encrypt(idfile:string, password:string) : void
Parameter | Description |
---|---|
Userid | NotesUserID (type). After setting the User id, documents in this database will be decrypted with encryption keys of this user id |
idfile | String. Provides the file path of id file. After setting it, all documents in this database will be decrypted with encryption keys of this id file. |
password | String. After setting the User id, documents in this database will be decrypted with encryption keys of this user id |
Usage
The 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.
Since mail encryption works differently, do not use this method if you want to mail an encrypted document. Instead, set the EncryptOnSend property to true, and use the send method.
Usage with XPages
This method can also
be used for encrypting XPages using the Userid, idfile,
and password parameters. To encrypt a document with a private
key on web or server use the following general code 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
Examples
This button encrypts the current document.var doc:NotesDocument = currentDocument.getDocument();
if (!doc.isEncrypted()) {
doc.encrypt();
doc.save()
}