# nip04.encrypt

**Method**

```javascript
async function nip04.encrypt(pubkey: string, plaintext: string): string;
```

**Response**

Returns ciphertext and iv as specified in nip-04.

<https://github.com/nostr-protocol/nips/blob/master/04.md>

**Code Example**

```javascript
const encrypted = await window.nostr.nip04.encrypt(pubkey, "Secret message");
```
