Generate a random lock token.

@param   {Function}  callback        Invoked with the token when complete
@param   {Error}     callback.err    An error that occurred, if any
@param   {string}    callback.token  The randomly generated token
@api private
767240
function(callback) {
    crypto.randomBytes(16, function(err, buffer) {
        if (err) {
            return callback(err);
        }

        return callback(null, buffer.toString('base64'));
    });
}
1064953
function generateRandomBytes (size, attempts, callback) {
  crypto.randomBytes(size, function onRandomBytes (err, buf) {
    if (!err) return callback(null, buf)
    if (!--attempts) return callback(err)
    setTimeout(generateRandomBytes.bind(null, size, attempts, callback), 10)
  })
}
194332
function (B, E, callback) {
            //var rng = new SeededRandom();
            var rng = new SecureRandom();
            var qs = B >> 1;
            this.e = parseInt(E, 16);
            var ee = new BigInteger(E, 16);
            var rsa = this;
            // These functions have non-descript names because they were originally for(;;) loops.
            // I don't know about cryptography to give them better names than loop1-4.
            var loop1 = function () {
                var loop4 = function () {
                    if (rsa.p.compareTo(rsa.q) <= 0) {
                        var t = rsa.p;
                        rsa.p = rsa.q;
                        rsa.q = t;
                    }
                    var p1 = rsa.p.subtract(BigInteger.ONE);
                    var q1 = rsa.q.subtract(BigInteger.ONE);
                    var phi = p1.multiply(q1);
                    if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
                        rsa.n = rsa.p.multiply(rsa.q);
                        rsa.d = ee.modInverse(phi);
                        rsa.dmp1 = rsa.d.mod(p1);
                        rsa.dmq1 = rsa.d.mod(q1);
                        rsa.coeff = rsa.q.modInverse(rsa.p);
                        setTimeout(function () {
                            callback()
                        }, 0); // escape
                    } else {
                        setTimeout(loop1, 0);
                    }
                };
                var loop3 = function () {
                    rsa.q = nbi();
                    rsa.q.fromNumberAsync(qs, 1, rng, function () {
                        rsa.q.subtract(BigInteger.ONE).gcda(ee, function (r) {
                            if (r.compareTo(BigInteger.ONE) == 0 && rsa.q.isProbablePrime(10)) {
                                setTimeout(loop4, 0);
                            } else {
                                setTimeout(loop3, 0);
                            }
                        });
                    });
                };
                var loop2 = function () {
                    rsa.p = nbi();
                    rsa.p.fromNumberAsync(B - qs, 1, rng, function () {
                        rsa.p.subtract(BigInteger.ONE).gcda(ee, function (r) {
                            if (r.compareTo(BigInteger.ONE) == 0 && rsa.p.isProbablePrime(10)) {
                                setTimeout(loop3, 0);
                            } else {
                                setTimeout(loop2, 0);
                            }
                        });
                    });
                };
                setTimeout(loop2, 0);
            };
            setTimeout(loop1, 0);
        }
430981
function(callback) {

      // Detect server errors
      var t = this, server = t.get('server');
      server.on('clientError', function(err){
        console.error('Client error detected on server', err);
        t.trigger('error', err);
      });
      server.on('close', function(err){
        server.hasEmittedClose = true;
        t.stop();
      });

      // Notify that we've started
      t.isListening = true;
      if (callback) {
        callback(null);
      }
      t.trigger('start');
    }
506240
function generateSetupToken (tokenPath) {
  mkdirp.sync(path.dirname(tokenPath))

  var token = crypto.randomBytes(256).toString('hex')
  try {
    fs.writeFileSync(tokenPath, token, 'utf8')
  } catch (e) {
    throw new Error('Unable to save setup token to ' + tokenPath)
  }
  return token
}
1254228
function makeCallback(entryCaller, entryStack, shadow = false) {
  /**
   * This callback should be called when an asynchronous error occurred.
   * @param {(string|Error)} messageOrError A message string or an _Error_ object at the point of actual error.
   * @returns {Error} An error with the updated stack which includes the callee.
   */
  function cb(messageOrError) {
    const caller = getCallerFromArguments(arguments)
    const { stack: errorStack } = new Error()
    const calleeStackLine = getCalleeStackLine(errorStack)
    const isError = messageOrError instanceof Error
    const message = isError ? messageOrError.message : messageOrError

    const stackHeading = getStackHeading(message)
    const entryHasCallee = caller !== null && entryCaller === caller
    const stackMessage = [
      stackHeading,
      ...(entryHasCallee || shadow ? [entryStack] : [
        calleeStackLine,
        entryStack,
      ]),
    ].join('\n')

    const stack = cleanStack(stackMessage)
    const properties = { message, stack }
    const e = isError ? messageOrError : new Error()

    return /** @type {Error} */ (Object.assign(/** @type {!Object} */ (e), properties))
  }

  return cb
}
524445
function( callback ){
      var tm = this;

      setTimeout(function () {
        var returnValue;

        //check for template existance.
        if (tm.template) {
          tm._tokenize();
          returnValue = tm._tokens;

          // execute callback.
          if (callback) {
            callback( returnValue );
          }
        } else {
          throw "ParseError: No template to parse.";
        }
      }, 0);
    }
343682
function(callback) {
			var t = this;
	
			t._interval(callback);

			t.timer = setInterval(function() {		
				t._interval(callback);
			}, this.interval);
		}
901246
function(callback, guid) {
		// If the guid has not been supplied then create a new one.
		guid = guid || '_hellojs_' + parseInt(Math.random() * 1e12, 10).toString(36);

		// Define the callback function
		window[guid] = function() {
			// Trigger the callback
			try {
				if (callback.apply(this, arguments)) {
					delete window[guid];
				}
			}
			catch (e) {
				console.error(e);
			}
		};

		return guid;
	}
1310094
function yubikey__genNonceAsync(callback) {
    // Create a secure, random nonce value
    crypto.randomBytes(40, function(err, buf) {
      if (err) return callback(err);
      return callback(null, buf.toString('hex').slice(0,40));
    });
  }
155080
function createAuthKey(callback, channel) {

    flow.retryUntilIsDone(callback, null,
        function (callback) {
            flow.runSeries([
                require('./request-pq'),
                require('./request-dh-params'),
                require('./set-client-dh-params')
            ], callback, channel);
        });
}
874748
function getToken (token, callback) {

    if (token != null &&
        token != '') {

        // Fetch token from database or cache

        if (token == 'h328hdkasjd3') {

            var record = { algorithm: 'hmac-sha-256',   // Required
                secret: '23hdkdho2893hdkjd',            // Required
                userId: 'johndoe'                       // Application-specific field
            };

            callback(record);
        }
        else {

            // Token not found

            callback({});
        }
    }
    else {

        // Invalid token request

        callback({});
    }
}
207137
function attemptLock(lock, timeout, callback) {
  var lockPath;
  var sequenceNodeName;
  var timerId = null;
  var start = Date.now();

  createNode(lock, afterCreate);

  function afterCreate(err, nodePath) {
    if (err) {
      return exit(err);
    }

    lockPath = nodePath;

    sequenceNodeName = nodePath.substring(lock.basePath.length + 1);

    getSortedChildren(lock, afterGetChildren);
  }

  function afterGetChildren(err, list) {
    if (exited()) {
      return;
    }
    if (err) {
      return exit(err);
    }

    var result = lock.driver.getsTheLock(list, sequenceNodeName,
      lock.maxLeases);

    if (result.error) {
      return exit(result.error);
    }
    else if (result.hasLock) {
      return exit(null, lockPath);
    }

    var watchPath = utils.join(lock.basePath, result.watchPath);

    lock.client
      .getData()
      .usingWatcher(watcher)
      .forPath(watchPath, afterGetData);

    setTimer();
  }

  function afterGetData(err) {
    if (exited() || !err) {
      return;
    }

    if (err.getCode() === Exception.NO_NODE) {
      getSortedChildren(lock, afterGetChildren);
    }
    else {
      exit(err);
    }
  }

  function watcher(event) {
    if (!exited() && event.getType() === Event.NODE_DELETED) {
      getSortedChildren(lock, afterGetChildren);
    }
  }

  function setTimer() {
    if (timerId) {
      return;
    }

    if (timeout >= 0) {
      timeout -= Date.now() - start;

      if (timeout <= 0) {
        return sayBye();
      }

      timerId = setTimeout(sayBye, timeout);
    }
  }

  function sayBye() {
    exit(new TimeoutError('Could not acquire lock %s', lock.basePath));
  }

  function exit(err, path) {
    if (timerId) {
      clearTimeout(timerId);
      timerId = -1;
    }

    var cb = callback;
    callback = null;

    if (!err) {
      cb(null, path);
    }
    else if (lockPath) {
      deleteNode(lock, lockPath, proceed);
    }
    else {
      cb(err);
    }

    function proceed(deleteError) {
      if (deleteError) {
        cb(deleteError);
      }
      else {
        cb(err);
      }
    }
  }

  function exited() {
    return !callback;
  }
}
1107346
function makeCallback(callback) {
  if (_.isFunction(callback)) {
    return callback;
  }
  var result = function() { return callback; };
  result._callback = callback;
  return result;
}
312323
function(callback) {
        block = "";
        for(var i = 0; i < opts.size; i++) block + ".";
        testAbility(callback);
    }
977918
function addCallback (t, data) {
  var result = data.result || data.error;
  cbid = data.id;
  if (t.callbacks[cbid]) {
    if (data.result) {
      t.callbacks[cbid](result);
    } else {
      t.callbacks[cbid](result, 'error');
    }
  }
}
735110
function newRandomKey(coll, key, currentKey){
      var randKey;
      do {
        randKey = coll[Math.floor(coll.length * Math.random())][key];
      } while (randKey == currentKey);
      return randKey;
    }