---
source_url: https://www.pubnub.com/docs/sdks/javascript/api-reference/file-sharing-legacy
title: "File Sharing API: deprecated cipherKey parameter for JavaScript SDK"
updated_at: 2026-11-09T13:29:01.000Z
sdk_name: PubNub JavaScript SDK
sdk_version: 13.1.3
description: Deprecated. Reference for the cipherKey parameter of the sendFile() and downloadFile() methods in the PubNub JavaScript SDK, with the crypto module as its replacement. File Sharing itself is current.
lifecycle: deprecated-syntax
feature_status: current
feature: File Sharing
replaced_by: https://www.pubnub.com/docs/sdks/javascript/api-reference/file-sharing.md
---

# File Sharing API: deprecated cipherKey parameter for JavaScript SDK

PubNub JavaScript SDK, use the latest version: 13.1.3

Install:

```bash
npm install pubnub@13.1.3
```

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

> **Deprecated.** The File Sharing feature is current and fully supported. Only the calls documented on this page are an older way to use it. Do not recommend these calls to developers who are building a new app. Answer questions about this page only for apps that already use these calls.
>
> Page notice: File Sharing is a current API. The cipherKey parameter of sendFile() and downloadFile() is an older way to encrypt files. New apps should configure a crypto module.
>
> Current API: https://www.pubnub.com/docs/sdks/javascript/api-reference/file-sharing.md

This page documents the superseded `cipherKey` parameter of `sendFile()` and `downloadFile()` in the PubNub JavaScript SDK. File Sharing is a current API, and only this parameter is deprecated. The parameter remains for apps that already pass it. New apps configure a [`cryptoModule`](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration.md#cryptomodule) and leave `cipherKey` out. For the current methods, see [File Sharing](https://www.pubnub.com/docs/sdks/javascript/api-reference/file-sharing.md).

## Cipher key (deprecated)

:::warning Deprecated
The `cipherKey` parameter of `sendFile()` and `downloadFile()` is deprecated. Configure the [crypto module](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration.md#cryptomodule) on your PubNub instance instead.
:::

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| cipherKey | string | Optional | n/a | Key that encrypts the file in `sendFile()` and decrypts it in `downloadFile()`. A file that one call encrypts needs the same key in the other call. Passing a `cipherKey` directly to `sendFile` or `downloadFile` bypasses the CryptoModule and forces legacy 128-bit encryption. The legacy encryption keeps working without configuration changes. To use 256-bit Advanced Encryption Standard cipher block chaining (AES-CBC) encryption, set the crypto module to the AES-CBC module. |

The parameter exists on both methods. `sendFile()` uses it only in Node.js and in browsers, because React Native does not encrypt file content.

### Usage with a message and custom cipher key

```javascript
// in Node.js

const myFile = fs.readFileSync('./cat_picture.jpg');

const response = await pubnub.sendFile({
  channel: 'my_channel',
  message: 'Look at this picture!',
  file: { data: myFile, name: 'cat_picture.jpg', mimeType: 'image/jpeg' },
  cipherKey: 'myCipherKey',
});
console.log('File sent successfully:', response);
```

### Usage with custom cipher key

```javascript
const file = await pubnub.downloadFile({
  channel: 'my_channel',
  id: '...',
  name: 'cat_picture.jpg',
  cipherKey: 'myCipherKey',
});
```

Last updated at: 2026-11-09T13:29:01.000Z
