> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# encryptKeyShare

> Encrypts a key share with a password

## Function Signature

```typescript theme={"system"}
encryptKeyShare(params: {
  keyShare: any;
  password: string;
}): Promise<string>
```

## Description

Encrypts a key share with a password. This function provides a way to securely encrypt key shares for storage or transmission.

## Parameters

### Required Parameters

* **`keyShare`** (`any`) - The key share to encrypt
* **`password`** (`string`) - Password for encryption

## Returns

* **`Promise<string>`** - The encrypted key share

## Example

```typescript theme={"system"}
import { authenticatedSvmClient } from './client';

const svmClient = await authenticatedSvmClient();

const encryptedShare = await svmClient.encryptKeyShare({
  keyShare: {
    chainName: 'solana',
    keyShare: '0xYourKeyShare',
  },
  password: 'your-password',
});

console.log('Encrypted share:', encryptedShare);
```

## Error Handling

```typescript theme={"system"}
try {
  const encryptedShare = await svmClient.encryptKeyShare({
    keyShare: {
      chainName: 'solana',
      keyShare: '0xYourKeyShare',
    },
    password: 'your-password',
  });
  console.log('Key share encrypted successfully');
} catch (error) {
  console.error('Failed to encrypt key share:', error);
}
```

## Related Functions

* [`decryptKeyShare()`](/node/reference/svm/decrypt-key-share) - Decrypt an encrypted key share
* [`exportExternalServerKeyShares()`](/node/reference/svm/export-external-server-key-shares) - Export external server key shares
