How to use the chloride.randombytes 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 auditdrivencrypto / private-box / index.js View on Github external
function randombytes(n) {
  var b = new Buffer(n)
  sodium.randombytes(b)
  return b
}
github dominictarr / pull-box-stream / index.js View on Github external
function randomSecret(n) {
  var rand = new Buffer(n)
  sodium.randombytes(rand)
  return rand
}
github ssbc / ssb-keys / sodium.js View on Github external
generate: function (seed) {
    if(!seed) sodium.randombytes(seed = new Buffer(32))

    var keys = seed ? sodium.crypto_sign_seed_keypair(seed) : sodium.crypto_sign_keypair()
    return {
      curve: 'ed25519',
      public: keys.publicKey,

      //so that this works with either sodium
      //or libsodium-wrappers (in browser)
      private: keys.privateKey || keys.secretKey
    }
  },