How to use the chloride.crypto_secretbox_open_easy function in chloride

To help you get started, we’ve selected a few chloride examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssbc / ssb-peer-invites / util.js View on Github external
function unbox (ctxt, key) {
  var b = Buffer.from(ctxt, 'base64')
  var ptxt = chloride.crypto_secretbox_open_easy(b, key.slice(0, 24), key)
  if(!ptxt) return
  try {
    return JSON.parse(ptxt)
  } catch(err) {
    console.error(err)
  }
}
github dominictarr / pull-box-stream / index.js View on Github external
function unbox_detached (mac, boxed, nonce, key) {
  return sodium.crypto_secretbox_open_easy(concat([mac, boxed]), nonce, key)
}
github ssbc / ssb-keys / index.js View on Github external
exports.secretUnbox = function secretUnbox (ctxt, key) {
  var ptxt = sodium.crypto_secretbox_open_easy(ctxt, key.slice(0, 24), key)
  if(!ptxt) return
  return JSON.parse(ptxt.toString())
}