decrypt()
Othent JS SDK decrypt() function
API
decrypt(ciphertext: BinaryDataType): Promise<Uint8Array>;ciphertext: BinaryDataType
ciphertext: BinaryDataTypereturn Promise<Uint8Array>
return Promise<Uint8Array>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);
// Decrypt the same data using RSA:
const decrypted = await othent.decrypt(encrypted);
const decryptedString = new TextDecoder().decode(decrypted);
console.log(`The original secret message is "${ decryptedString }".`);Last updated