How to use the sodium-native.crypto_box_SEALBYTES function in sodium-native

To help you get started, we’ve selected a few sodium-native 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 samuelmaddock / metastream / app / browser / platform / swarm / socket.js View on Github external
function unseal(cipher, publicKey, secretKey) {
  if (cipher.length < sodium.crypto_box_SEALBYTES) return null
  var msg = new Buffer(cipher.length - sodium.crypto_box_SEALBYTES)
  if (!sodium.crypto_box_seal_open(msg, cipher, publicKey, secretKey)) return null
  return msg
}
github samuelmaddock / swarm-peer-server / lib / crypto.js View on Github external
function unseal(cipher, publicKey, secretKey) {
  if (cipher.length < sodium.crypto_box_SEALBYTES) return null
  var msg = Buffer.alloc(cipher.length - sodium.crypto_box_SEALBYTES)
  if (!sodium.crypto_box_seal_open(msg, cipher, publicKey, secretKey)) return null
  return msg
}
github samuelmaddock / metastream / app / browser / platform / swarm / socket.js View on Github external
function unseal(cipher, publicKey, secretKey) {
  if (cipher.length < sodium.crypto_box_SEALBYTES) return null
  var msg = new Buffer(cipher.length - sodium.crypto_box_SEALBYTES)
  if (!sodium.crypto_box_seal_open(msg, cipher, publicKey, secretKey)) return null
  return msg
}
github automerge / hypermerge / src / Crypto.ts View on Github external
export function openSealedBox(
  keyPair: EncodedEncryptionKeyPair,
  sealedBox: EncodedSealedBox
): Buffer {
  const keyPairBuffer = decodePair(keyPair)
  const sealedBoxBuffer = decode(sealedBox)
  const message = Buffer.alloc(sealedBoxBuffer.length - sodium.crypto_box_SEALBYTES)
  const success = sodium.crypto_box_seal_open(
    message,
    sealedBoxBuffer,
    keyPairBuffer.publicKey,
    keyPairBuffer.secretKey
  )
  if (!success) throw new Error('Unable to open sealed box')
  return message
}
github samuelmaddock / metastream / app / browser / platform / swarm / socket.js View on Github external
function seal(msg, publicKey) {
  var cipher = new Buffer(msg.length + sodium.crypto_box_SEALBYTES)
  sodium.crypto_box_seal(cipher, msg, publicKey)
  return cipher
}
github samuelmaddock / swarm-peer-server / lib / crypto.js View on Github external
function seal(msg, publicKey) {
  var cipher = Buffer.alloc(msg.length + sodium.crypto_box_SEALBYTES)
  sodium.crypto_box_seal(cipher, msg, publicKey)
  return cipher
}