Othent
  • 👋Welcome to Othent
  • 🥪JS SDK
    • Getting Started
    • Events
    • Error Handling
    • Binary Data Types Utils
    • TypeScript Types
    • Config Constants
  • 🥪JS SDK API
    • constructor()
    • startTabSynching()
    • completeConnectionAfterRedirect()
    • connect()
    • disconnect()
    • requireAuth()
    • isAuthenticated
    • getActiveAddress()
    • getActivePublicKey()
    • getAllAddresses()
    • getWalletNames()
    • getUserDetails()
    • getSyncActiveAddress()
    • getSyncActivePublicKey()
    • getSyncAllAddresses()
    • getSyncWalletNames()
    • getSyncUserDetails()
    • sign() (transaction)
    • dispatch() (transaction)
    • encrypt()
    • decrypt()
    • signature()
    • signDataItem()
    • signMessage()
    • verifyMessage()
    • privateHash()
    • walletName
    • walletVersion
    • config
    • getArweaveConfig()
    • getPermissions()
  • Demos
    • 🍏SDK playground / demo
    • 🍏SDK playground / demo GitHub
    • 🍎File upload app example
    • 🍎File upload app example GitHub
  • 📚External libraries
    • arweave-js
    • Arweave Wallet Kit
  • Additional Links
    • 🌐Othent.io
    • 🌐Discord
    • 🌐GitHub
    • 🌐X
Powered by GitBook
On this page
  • API
  • plaintext: string | BinaryDataType
  • return Promise<Uint8Array>
  • Example usage
  1. JS SDK API

encrypt()

Othent JS SDK encrypt() function

Previousdispatch() (transaction)Nextdecrypt()

Last updated 8 months ago

The encrypt() function encrypts the data using the active user's private key so that, when stored on Arweave, it is only accessible to that specific user, similarly to the .

This is useful for applications such as private file storage apps or mail/messaging platforms.

Limitation: There's currently an 8KB limit in data size when using Othent, but this is currently being worked on. Track the progress on this .

Limitation: Also, the only currently available encryption/decryption algorithm is AES (AES256-GCM).

This function assumes (and requires) a user is authenticated. See .

API

encrypt(plaintext: string | BinaryDataType): Promise<Uint8Array>;

plaintext: string | BinaryDataType

The data to be encrypted with the user's private key, which can be of type string, , or .

return Promise<Uint8Array>

A Promise containing the encrypted data as .

Example usage

import { Othent } from "@othent/kms";

const othent = new Othent({ appInfo, throwErrors: false, ... });

// Make sure the user is authenticated, or prompt them to authenticate:
await othent.requireAuth();

// Encrypt data using RSA:
const encrypted = await othent.encrypt("This message will be encrypted");

console.log("Encrypted bytes:", encrypted);
🥪
Web Crypto API's encrypt()
GitHub issue
requireAuth()
ArrayBuffer
TypedArray
DataView
Uint8Array