encrypt
Encrypt a message using the wallet's encryption key (ECIES).
Usage
ts
const { encryptedMessage } = await Turing.encrypt({ message: "secret data" });Parameters
ts
interface EncryptParams {
message: string; // The plaintext message to encrypt
}| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The message to encrypt |
Returns
ts
interface EncryptResponse {
encryptedMessage: string; // The encrypted message string
}| Field | Type | Description |
|---|---|---|
encryptedMessage | string | The encrypted message |
Error Handling
This method throws an exception on failure. Use try-catch:
ts
try {
const { encryptedMessage } = await Turing.encrypt({ message: "secret data" });
console.log("Encrypted:", encryptedMessage);
} catch (error) {
console.error("Encryption failed:", error);
}Live Example
Live Example
Turing.encrypt()
Unknown
Use the wallet control in the top navigation before running this example.
Code Preview
const { encryptedMessage } = await Turing.encrypt({
"message": ""
});
console.log(encryptedMessage);