> ## 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 using a password

## Function Signature

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

## Description

Encrypts a key share using the provided password. This function is used for secure storage and transmission of key shares.

## Parameters

### Required Parameters

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

## Returns

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

## Example

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

const evmClient = await authenticatedEvmClient();

const encryptedShare = await evmClient.encryptKeyShare({
  keyShare: {
    chainName: 'base-sepolia',
    keyShare: '0x1234567890',
  },
  password: 'your-encryption-password',
});

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

## Key Share Format

```typescript theme={"system"}
interface KeyShare {
  chainName: string;
  keyShare: string;
}

const keyShare: KeyShare = {
  chainName: 'base-sepolia', // or your specific chain
  keyShare: '0x1234567890', // the actual key share
};
```

## Error Handling

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

## Related Functions

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