跳到主要内容

OnEncryption

Encrypts the document.

Syntax

expression.OnEncryption(obj, obj.type, obj.password, obj.data, obj.check, obj.docinfo, obj.hash, obj.error);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
objRequiredobjectThe encryption properties.
obj.typeRequiredstringThe type of encrypting operation: generatePassword - generates a password for the document, getPasswordByFile - sends the password when opening the document, encryptData - encrypts changes when co-editing, decryptData - decrypts changes when co-editing.
obj.passwordRequiredstringA string value specifying the password to access the document.
obj.dataRequiredstringEncrypted/decrypted changes.
obj.checkRequiredbooleanChecks if the encryption/decryption operation is successful or not (used only for encryptData or decryptData types).
obj.docinfoRequiredstringAn unencrypted part of the encrypted file.
obj.hashRequiredstringA string value specifying a file hash (sha256 by default).
obj.errorRequiredstringA string value specifying an error that occurs (the "" value means that the operation is successful).

Returns

This method doesn't return any data.

Example

window.Asc.plugin.executeMethod ("OnEncryption", [
{
"type": "getPasswordByFile",
"password": "123456",
"docinfo": "{docinfo}",
"hash": "sha256"
}
]);