> For the complete documentation index, see [llms.txt](https://aleo-hooks.gitbook.io/aleo-hooks/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aleo-hooks.gitbook.io/aleo-hooks/usedecrypt.md).

# useDecrypt

For decrypting a ciphertext

Hook parameters:

```typescript
interface IUseDecryptArguments {
    cipherText: string // Encrypted text
    tpk?: string // Transaction public key
    programId?: string // Program ID
    functionName?: string // Function name
    index?: number // Account index м/44'/0'/<account_index>'/0'
    enabled?: boolean // auto decrypt
}
```

Return values:

```typescript
// useDecrypt hook returns next fields
decryptedText: string // Decrypted text
loading: boolean // loading state
error: any // error message if something went wrong
decrypt: () => Promise<void> // a function to force decryption
```

Example (live demo <https://aleo-react-boilerplate.vercel.app/>):

```tsx
import { FC } from 'react'
import { useDecrypt } from 'aleo-hooks'

export const UseDecrypt: FC = () => {
    const { decryptedText, loading, error } = useDecrypt({ 
        cipherText: 'ciphertext1qgqtzwpwj2r0rw0md3zxlnnj9h7azun02f6tdm27u8ywxcsuw4pssp7xsp7edm749l4pd9s47wksc475dkhmjnl7yrzzylgnfyx2kfwkpqlsynj2' 
    })

    return (
        <div>
            {loading && <p>Loading...</p>}
            {error && <p>Something went wrong {JSON.stringify(error)}</p>}
            {decryptedText && <p>Decrypted text: {decryptedText}</p>}
        </div>
    )
}
```
