ArweaveKit Docs
  • 💳ARWEAVE WALLET KIT
    • Introduction to Arweave Wallet Kit
    • Setup
    • Connect Button
    • Hooks
    • Customization
  • 🤖Arweave Data Storage SDK
    • Introduction to the Arweave Data Storage SDK
  • Installation
  • Usage
  • Wallet
  • Configuration
  • Data Upload Service
  • ArweaveKit
    • Introduction
  • 🔐Wallets
    • Introduction to Wallets
    • Create Wallet
    • Get Wallet Address
    • Get Wallet Balance
    • Wallet Plugins
  • 🏦Transactions
    • Introduction to Transactions
    • Create Transaction
    • Sign Transaction
    • Post Transaction
    • Get Transaction Status
    • Get Transaction
    • Create and Post Transaction with Othent
    • Transaction Plugins
  • ✅AUTH
    • Introduction to Auth
    • Connect
    • Disconnect
    • Get Active Address
    • Get Permissions
    • Get Wallet Names
    • Get All Addresses
    • Get Active Public Key
    • Is Installed
    • Log In with Othent
    • Log Out with Othent
    • Get User Details with Othent
    • Auth Plugins
  • 🔐Encryption
    • Introduction to Encryption
    • Encrypt Data with AES
    • Decrypt Data with AES
    • Encrypt AES Key with RSA
    • Decrypt AES Key with RSA
    • Encryption Plugins
  • 🌐GRAPHQL
    • Introduction to GraphQL
    • Query All Arweave Transactions
    • Query Arweave Data
    • Query Arweave Transactions
    • GraphQL Plugins
  • 📘REFERENCES
    • ArweaveKit in Browser Environments
  • 🛠️SUPPORTING TOOLS
    • Arweave StarterKit
Powered by GitBook
On this page
  • Basic Syntax
  • Input Parameters
  • Returned Data

Was this helpful?

  1. Encryption

Encrypt Data with AES

Encrypt Data with the Advanced Encryption Standard (AES)

The encryptDataWithAES performs symmetric encryption using the Advanced Encryption Standard (AES), specifically the Galois/ Counter Mode (GCM). Symmetric encryption is optimal for data encryption and performs the encryption and decryption of data with a single key.

A new AES key is generated each time the function is called. The data is encrypted using this key and a randomly generated initialized vector (iv).

The iv is required for decryption as well, hence it is returned prepended to the encrypted data as a combined Array Buffer. The encryption key is returned as well, as part of the return object. The key is generated as a CryptoKey object however it is converted to a base64 encoded string before being returned.

Basic Syntax

The function is called as follows:

import { encryptDataWithAES } from 'arweavekit/encryption';

const encryptedDataObject = await encryptDataWithAES({params});

Input Parameters

The following params are available for this function and they must be passed in as an object:

  • data: ArrayBuffer : The data to be encrypted passed in as an ArrayBuffer. The ArrayBuffer is optimal for data encryption using AES-GCM and is one of the preferred types for uploading data on Arweave.

Example
const encryptedDataObject = await encryptDataWithAES({
    data: ArrayBuffer,
});

This encrypts the provided ArrayBuffer using the AES-GCM encryption method.

Returned Data

The function call returns the following data:

{
    rawEncryptedKeyAsBase64: Base64 string,
    combinedArrayBuffer: ArrayBuffer,
}
  • rawEncryptedKeyAsBase64: string : The encryption key generated at the time of data encryption using AES-GCM and encoded using Base64 format.

  • combinedArrayBuffer: ArrayBuffer : The combination of the random initialized vector prepended to the encrypted data as an ArrayBuffer.

PreviousIntroduction to EncryptionNextDecrypt Data with AES

Last updated 4 months ago

Was this helpful?

🔐