decrypt
Decrypts data from encrypt().
Parameter | Description |
|---|---|
| The object returned by |
| A pair object with the same |
| Optional function that receives the result. Leave it out to |
Returns the original data, in the same format it was passed to encrypt(). Returns null if the key is wrong or the data can't be decrypted.
Examples
// With await.
const pair = await holster.SEA.pair()
const enc = await holster.SEA.encrypt({message: "hello self"}, pair)
const dec = await holster.SEA.decrypt(enc, pair)
console.log(dec) // {message: "hello self"}
// With a callback.
holster.SEA.decrypt(enc, pair, dec => console.log(dec.message))Reading back data that was encrypted and stored:
const enc = await user.get("private")
const data = await holster.SEA.decrypt(enc, user.is)