Generates random bytes of specified length
@param {Number} len
@returns {Uint8Array}
554413
function random(len) {
    if (subtle) {
        return safeRandom(len);
    } else if (nodeCrypto) {
        return new Uint8Array(nodeCrypto.randomBytes(len));
    } else {
        throw new KdbxError(Consts.ErrorCodes.NotImplemented, 'Random not implemented');
    }
}
409126
function random (length) {
  // Guard
  if (length == null) {
    length = DEFAULT;
  } else if (!(typeof length === 'number' && length > 0)) {
    throw new Error('Length should be +ve Number');
  }

  // Fill buffer
  var bits = bitString.randomBits(6 * length);
  return baseURL.encode(bits);
}
428510
function (a, len) {
    if (a.length * 32 < len) { return a; }
    a = a.slice(0, Math.ceil(len / 32));
    var l = a.length;
    len = len & 31;
    if (l > 0 && len) {
      a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1);
    }
    return a;
  }
1251693
function randNum (n) {
  let sNum = ''
  for (let i = 0; i < n; i++) {
    sNum += tools.rnd(0, 9)
  }
  return sNum
}
622864
def random(self, length=None):
        
        if length is None:
            length = self._length

        random_num = int(binascii.b2a_hex(os.urandom(length)), 16)
        return int_to_string(random_num, self._alphabet, padding=length)[:length]
1006633
public static double[] randomDoubleArray(int len, Random r) {
    final double[] ret = new double[len];
    for(int i = 0; i < len; i++) {
      ret[i] = r.nextDouble();
    }
    return ret;
  }
593457
function(length) {
      var bytes, hex;
      if (length == null) {
        length = 32;
      }
      length /= 2;
      bytes = this.randomBytes(length);
      return hex = this.toHex(bytes).toUpperCase();
    }
66330
def generate_random_string(length=6):
    '''
    
    '''
    n = int(length / 2 + 1)
    x = binascii.hexlify(os.urandom(n))
    s = x[:length]
    return s.decode('utf-8')
715941
public static function randStr($len = 6)
    {
        $chars = str_repeat('0123456789', $len);
        $chars = str_shuffle($chars);
        $str   = substr($chars, 0, $len);
        return $str;
    }
1185059
public static function randNum($len = 4) {
		$rand = mt_rand(1, 9);

		for($i = 0; $i < $len - 1; $i++) {
			$rand .= mt_rand(0, 9);
		}

		return $rand;
	}
663251
public static byte[] intToBytesWithLen(int x, int len) {
        if(len <= 4) {
            return trailingBytes(intToBytes(x), len);
        } else {
            ByteBuffer bb = ByteBuffer.allocate(len);
            bb.position(len-4);
            bb.putInt(x);
            assert bb.remaining() == 0;
            return bb.array();
        }
    }
966375
function token(len = 20, encoding = 'hex') {
  return randomBytes(len)
    .then((buf) => {
      return buf.toString(encoding);
    });
}
1263558
function randomString(length, chars) {
  length = length || 8;
  chars = chars || '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  var result = '';
  for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
  return result;
}
13812
function randomBytesSync (size) {
  var err = null

  for (var i = 0; i < GENERATE_ATTEMPTS; i++) {
    try {
      return crypto.randomBytes(size)
    } catch (e) {
      err = e
    }
  }

  throw err
}
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)
  })
}
89761
def bytes(num, check_result=False):
    

    if num <= 0:
        raise ValueError("'num' should be > 0")
    buf = create_string_buffer(num)
    result = libcrypto.RAND_bytes(buf, num)
    if check_result and result == 0:
        raise RandError("Random Number Generator not seeded sufficiently")
    return buf.raw[:num]
1350891
def randombytes(size):
    
    buf = ffi.new("unsigned char[]", size)
    lib.randombytes(buf, size)
    return ffi.buffer(buf, size)[:]