Data encrypted with the user's wallet should be accessible by the owner of the private key. The decrypt() function allows applications to decrypt any piece of data encrypted with the user's private key, similarly to the webcrypto encrypt API.
Note: This function requires the DECRYPT permission.
Example usage
// connect to the extensionawaitwindow.arweaveWallet.connect(["ENCRYPT","DECRYPT"]);// encrypt data using RSA-OAEPconstencrypted=awaitarweaveWallet.encrypt(newTextEncoder().encode("This message will be encrypted"), { name:"RSA-OAEP" });console.log("Encrypted bytes:", encrypted);// now decrypt the same data using// the same algorithmconstdecrypted=awaitarweaveWallet.decrypt( encrypted, { name:"RSA-OAEP" });console.log("Decrypted data:",newTextDecoder().decode(decrypted));
Old (deprecated) usage
// connect to the extensionawaitwindow.arweaveWallet.connect(["ENCRYPT","DECRYPT"]);// encrypt dataconstencrypted=awaitwindow.arweaveWallet.encrypt(newTextEncoder().encode("This message will be encrypted"), { algorithm:"RSA-OAEP", hash:"SHA-256", });console.log("Encrypted bytes:", encrypted);// decrypt dataconstdecrypted=awaitwindow.arweaveWallet.decrypt( encrypted, { algorithm:"RSA-OAEP", hash:"SHA-256", });console.log("Decrypted data:",newTextDecoder().decode(decrypted));