decryptData
decryptData(
encryptedHex:string,address:string):Promise<string>
Defined in: src/react/useEncryption.ts:500Â
Decrypts data using AES-GCM with the stored encryption key.
This function uses the encryption key previously generated via requestEncryptionKey
to decrypt data. The key must exist in memory before calling this function, or it
will throw an error prompting the user to sign a message.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
Encrypted data as hex string (IV + ciphertext + auth tag) |
|
|
|
The wallet address associated with the encryption key |
Returns
Promise<string>
Decrypted data as string
Throws
Error if encryption key is not found in memory or if decryption fails
Example
import { decryptData, requestEncryptionKey } from "@reverbia/sdk/react";
// First, ensure encryption key exists
await requestEncryptionKey(walletAddress);
// Then decrypt data
const encrypted = localStorage.getItem("mySecret");
if (encrypted) {
const decrypted = await decryptData(encrypted, walletAddress);
console.log("Decrypted:", decrypted);
}Last updated on