How to use the chloride.crypto_secretbox_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 box (data, key) {
  if(!data) return
  var b = Buffer.from(JSON.stringify(data))
  return chloride.crypto_secretbox_easy(b, key.slice(0, 24), key).toString('base64')
}
github ssbc / ssb-keys / index.js View on Github external
exports.secretBox = function secretBox (data, key) {
  if(!data) return
  var ptxt = Buffer.from(JSON.stringify(data))
  return sodium.crypto_secretbox_easy(ptxt, key.slice(0, 24), key)
}