# encrypt

{% hint style="info" %}
encrypt method returns a promise, which **resolves** when Dashboard successfully encrypted your payload and **rejects** if missing requirements or if something went wrong with Dashboard encryption api.
{% endhint %}

## How to use

```jsx
import { Plugin } from '@root'

Plugin.encrypt({
    ...ENCRYPT_PARAMS
}).then(data).catch(error)
```

## Encrypt params

| Param        | Typeof | Default | Required | Description                                          |
| ------------ | ------ | ------- | :------: | ---------------------------------------------------- |
| **payload**  | String | null    |     ✅    | the data that you want Dashboard to encrypt for you. |
| **password** | String | null    |     ✅    | the encryption password to use to encrypt your data. |

## Encrypt custom payload

```jsx
import { Plugin } from '@root'

const dataToEncrypt = {
    username: 'Dashboard user',
    secretId: 'supper-secret-id'
}

Plugin.encrypt({
    payload: JSON.stringify(dataToEncrypt),
    password: 'my-super-secret-password'
}).then(encryptedData => {
    console.log(encryptedData)
}).catch(error => {
    console.error(error)
})
```
