OthentKMS encrypt() function

The encrypt() function encrypts the data using the connected users private key so that when stored on Arweave, it is only accessible to a specific user.

Example Usage

To use the encrypt() function, import it from the @othent/kms package and call it within an asynchronous function as follows:

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

const handleDecrypt = async () => {
	const data = "Encrypt this data please.";
  const res = await encrypt(data);
  console.log(res);
}; 

The encrypt() function requires a the data argument is the form of a string or Uint8Array for successful execution.

<aside> ⚠️ Note: A user must be logged in to an application to successfully encrypt data.

</aside>

Result

On successful execution, the function returns the encrypted data as follows:

{
	data: (106) [10, 36, 0, 128, 140, 86, 79, 28, 89, 212, 76, 138, 149, 124, 117, 148, 187, 23, 83, 9, 200, 122, 54, 183, 129, 142, 9, 99, 238, 161, 111, 238, 110, 175, 88, 197, 142, 156, 18, 66, 0, 88, 248, 5, 205, 145, 125, 41, 111, 217, 90, 194, 164, 212, 185, 159, 53, 237, 105, 35, 144, 150, 118, 69, 36, 122, 35, 200, 173, 12, 5, 227, 97, 187, 139, 0, 213, 4, 187, 64, 177, 135, 168, 241, 116, 161, 129, 152, 122, 196, 185, 248, 74, 217, 199, 3, 255, 56, 157, 123, …],
	type: "Buffer",
}

Applications can then use this encrypted for other operations or store it for future decryption. This feature is particularly useful for applications (such as private file storage apps, mail clients, messaging platforms) or users that might want to secure their information before uploading to Arweave.