Wander Docs
HomeGithub
  • ๐Ÿ‘‹Welcome to Wander
  • โ›๏ธDeveloper tooling
    • Wander Devtools
    • ArLocal Devtools
  • ๐Ÿ“šExternal libraries
    • Arweave Wallet Kit
    • arweave-js
  • ๐Ÿ”ญDemos
    • Applications
  • ๐ŸงชAPI
    • Intro
    • Events
    • Connect
    • Disconnect
    • Get active address
    • Get active public key
    • Get all addresses
    • Get wallet names
    • Sign Transaction
    • Dispatch Transaction
    • Sign DataItem
    • Batch Sign DataItem
    • Sign message
    • Verify message
    • Private hash
    • User Tokens
    • Token Balance
    • Encrypt
    • Decrypt
    • Crypto signature
    • Subscriptions
    • Retrive permissions
    • Retrive Gateway Config
  • ๐ŸŒWander.app
Powered by GitBook
On this page
  • Example usage
  • Old (deprecated) usage

Was this helpful?

Edit on GitHub
  1. API

Encrypt

Wander Injected API encrypt() function

PreviousToken BalanceNextDecrypt

Last updated 3 months ago

Was this helpful?

Some applications (such as private file storage apps, mail clients, messaging platforms) might want to upload content to Arweave that is encrypted and only accessible by the user via their private key. The encrypt() function does just that: it encrypts data with the active private key and returns the encrypted bytes, similarly to the .

Argument
Type
Description

data

The data to be encrypted with the user's private key

algorithm

An object specifying the algorithm to be used and any extra parameters if required

Note: This function requires the permission.

Example usage

// connect to the extension
await window.arweaveWallet.connect(["ENCRYPT"]);

// encrypt data using RSA-OAEP
const encrypted = await arweaveWallet.encrypt(
    new TextEncoder().encode("This message will be encrypted"),
    { name: "RSA-OAEP" }
);

console.log("Encrypted bytes:", encrypted);

Old (deprecated) usage

// connect to the extension
await window.arweaveWallet.connect(["ENCRYPT"]);

// encrypt data
const encrypted = await window.arweaveWallet.encrypt(
  new TextEncoder().encode("This message will be encrypted"),
  {
    algorithm: "RSA-OAEP",
    hash: "SHA-256",
  }
);

console.log("Encrypted bytes", encrypted);

, or

, , or

๐Ÿงช
ArrayBuffer
TypedArray
DataView
RsaOaepParams
AesCtrParams
AesCbcParams
AesGcmParams
webcrypto encrypt API
ENCRYPT