Encrypt an Excel Workbook with Aspose.Cells Cloud API – Quick cURL & SDK Examples
This REST API encrypts an Excel workbook.
Prerequisites
- A valid Aspose Cloud client ID and client secret.
- An access token obtained via OAuth 2.0 (see the Authentication note below).
- The workbook to be encrypted must already exist in your Aspose Cloud storage.
- Supported file formats:
.xlsx,.xlsb.
Authentication
All requests must include an Authorization header containing a bearer token:
Authorization: Bearer <access_token>
Obtain the token by sending a POST request to the Aspose Cloud OAuth endpoint with your client ID and secret. The token is valid for a limited time; refresh it as needed.
Query Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| folder | string | ✗ | Folder path of the original workbook. |
| storageName | string | ✗ | Name of the storage to use. |
Request Body Parameter
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| encryption | WorkbookEncryptionRequest | ✓ | Encryption settings for the workbook. |
WorkbookEncryptionRequest
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| EncryptionType | string | ✓ | Encryption algorithm. See the table below for supported values and their meanings. |
| KeyLength | integer | ✗ | Length of the encryption key in bits (ignored for XOR and Compatible). |
| Password | string | ✓ | Password used for encryption. |
EncryptionType values
| Value | Description |
|---|---|
XOR |
Simple XOR algorithm (legacy, low security). |
Compatible |
Excel 97‑2003 compatible encryption (40‑bit). |
EnhancedCryptographicProviderV1 |
AES‑128 with SHA‑1 hash. |
StrongCryptographicProvider |
AES‑256 with SHA‑512 hash (strongest). |
REST API
| API | Type | Description | Swagger Link |
|---|---|---|---|
| /cells/{name}/encryption | POST | Encrypt Excel document | PostEncryptDocument |
The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.
You can use the cURL command‑line tool to access Aspose.Cells web services easily. The following example shows how to make a call to the Cloud API with cURL.
Cloud SDK Family
Using an SDK is the best way to speed up development. An SDK handles low‑level details so you can focus on your project tasks. Please check out the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.
The following code examples demonstrate how to call Aspose.Cells web services using various SDKs: