window.Asc.plugin.executeMethod("OnEncryption", [args], callback)

Description

Defines the method that allows encrypting the document.

Usage

This method should be used in the following way:

window.Asc.plugin.executeMethod("OnEncryption", [obj]);

Where obj is a JSON object of the following form (JSON):

{
    "type" : "string",
    "password" : "string",
    "data" : "string",
    "check" : boolean,
    "docinfo" : "string",
    "hash" : "string",
    "error" : "string"
}

The obj object can have the following values:

  • "type" (e.g. {"type": "encryptData"}) specifies the type of encrypting operation (generatePassword - generates a password for the document, getPasswordByFile - sends the password when opening the document, setPasswordByFile - sets a password to the document, encryptData - encrypts changes when co-editing, decryptData - decrypts changes when co-editing);
  • "password" (e.g. {"password": "password"}) is a string value specifying the password to access the document;
  • "data" (e.g. {"data": "{data}"}) is encrypted/decrypted changes;
  • "check" (e.g. {"check": true}) checks if the encryption/decryption operation is successful or not (used only for encryptData/decryptData types);
  • "docinfo" (e.g. {"docinfo": "{docinfo}"}) is an unencrypted part of an encrypted file;
  • "hash" (e.g. {"hash": "sha256"}) is a string value specifying a file hash ("sha256" by default);
  • "error" (e.g. {"error": "no_build"}) is a string value specifying the error that occurs (the "" value means that the operation is successful).
Returns

The method returns the obj object.

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