Encrypt 接口描述

 

用于Word加密。

接口方法1: encryptDocumentInRequest()设置密码

HTTP 请求方法:PUT

请求URL:https://api.e-iceblue.cn/v1/word/document/encryptInRequest

请求参数:

参数 是否必选 类型 可选值范围 说明
file string 原文档
oldPassword string 原文档密码,没有则为null
newPassword string 新密码
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using System.IO;

namespace EncryptDocumentInRequest
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static EncryptApi encryptApi = new EncryptApi(wordConfiguration);
        static void Main(string[] args)
        {
            Stream inputFile = new FileStream("D:/inputFile/encryptDocument.docx", FileMode.Open);
            string oldPassword = null;
            string newPassword = "123456";
            encryptApi.EncryptDocumentInRequest(inputFile, oldPassword, newPassword);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.EncryptApi;

import java.io.File;

public class EncryptDocumentInRequest {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static EncryptApi encryptApi = new EncryptApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        File inputFile = new File("D:/inputFile/encryptDocument.docx");
        String oldPassword = null;
        String newPassword = "123456";
        encryptApi.encryptDocumentInRequest(inputFile, oldPassword, newPassword);
    }
}

接口方法2: encryptDocument()设置密码

HTTP请求方法:PUT

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/encrypt

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
oldPassword string 原文档密码,没有则为null
newPassword string 新密码
pfxFile file Pfx证书文件
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace EncryptDocument
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static EncryptApi encryptApi = new EncryptApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "encryptDocument.docx";
            string folder = "input";
            string oldPassword = null;
            string newPassword = "123456";
            string destFilePath = "output/encryptDocument_output.docx";
            string storage = null;
            encryptApi.EncryptDocument(name, destFilePath, folder, storage, oldPassword, newPassword);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.EncryptApi;

public class EncryptDocument {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static EncryptApi encryptApi = new EncryptApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "encryptDocument.docx";
        String folder = "input";
        String oldPassword = null;
        String newPassword = "123456";
        String destFilePath = "output/encryptDocument_output.docx";
        String storage = null;
        encryptApi.encryptDocument(name, destFilePath, folder, storage, oldPassword, newPassword);
    }
}