Package java.security

Examples of java.security.SecureRandom.nextInt()


        (new Thread()
        {
            public void run()
            {
                SecureRandom random = new SecureRandom();
                random.nextInt();

                synchronized (lock)
                {
                    secRandom = random;
                    initializing = false;
View Full Code Here


    long startTime = System.nanoTime();
    SecureRandom sr = new SecureRandom();
    for (int i=1; i < 1000000; i++){
      try {
        ProxyUsers.authorize(proxyUserUgi,  "1.2.3."+ sr.nextInt(testRange));
       } catch (AuthorizationException e) {
      }
    }
    long stopTime = System.nanoTime();
    long elapsedTime = stopTime - startTime;
View Full Code Here

    protected String createSecKey() {
        SecureRandom random = new SecureRandom();
        byte[] data = new byte[16];
        for (int i = 0; i < 4; ++i) {
            int val = random.nextInt();
            data[i * 4] = (byte) val;
            data[i * 4 + 1] = (byte) ((val >> 8) & 0xFF);
            data[i * 4 + 2] = (byte) ((val >> 16) & 0xFF);
            data[i * 4 + 3] = (byte) ((val >> 24) & 0xFF);
        }
View Full Code Here

        digest.reset();
        byte[] hash = digest.digest(messageImprint);

        // 32-bit cryptographic nonce
        SecureRandom random = new SecureRandom();
        int nonce = random.nextInt();

        // generate TSA request
        TimeStampRequestGenerator tsaGenerator = new TimeStampRequestGenerator();
        tsaGenerator.setCertReq(true);
        ASN1ObjectIdentifier oid = getHashObjectIdentifier(digest.getAlgorithm());
View Full Code Here

    int ra, rb;
    try
      {
        prng1 = SecureRandom.getInstance("SHA1PRNG");
        prng2 = SecureRandom.getInstance("SHA1PRNG");
        ra = prng1.nextInt();
        rb = prng2.nextInt();
        harness.check(ra != rb,
                      "Similar SecureRandoms MUST NOT generate same bytes when "
                      + "not explicitly seeded");
View Full Code Here

        prng1 = SecureRandom.getInstance("SHA1PRNG");
        prng1.setSeed(98243647L);
        prng2 = SecureRandom.getInstance("SHA1PRNG");
        prng2.setSeed(98243647L);
        ra = prng1.nextInt();
        rb = prng2.nextInt();
        harness.check(ra == rb,
                      "Similar SecureRandoms MUST generate same bytes when "
                      + "similarly seeded");
      }
View Full Code Here

    try
    {
      SecureRandom wheel = SecureRandom.getInstance("SHA1PRNG");
      for (int i = 0; i < len; i++)
      {
        int nextChar = wheel.nextInt(alphaNumberic.length);
        randomChars[i] = alphaNumberic[nextChar];
      }
      random = new String(randomChars);
    }
    catch (NoSuchAlgorithmException e)
View Full Code Here

        CryptoProviderTools.installBCProvider();

        // Run java seed collector, that can take a little time the first time it is run
        log.trace(">init initializing random seed");
        SecureRandom rand = new SecureRandom();
        rand.nextInt();
       
        //
        // Start services that requires calling other beans or components
        //
       
View Full Code Here

          String key = "abc" + (rnd.nextDouble() * iterations);
          keys.add(key);
          map.put(key, new BufferedWebResponse(null));

          int randomMax = keys.size() - 1;
          int toRemove = randomMax == 0 ? 0 : rnd.nextInt(randomMax);
          String key2 = keys.get(toRemove);
          map.remove(key2);
        }
        endLatch.countDown();
      }
View Full Code Here

        if (boundary == null) {
            StringBuilder b = new StringBuilder();
            Random random = new SecureRandom();
           
            for (int i = 0; i < 16; i++) {
                b.append(BOUNDARY_CHARACTERS[random.nextInt(BOUNDARY_CHARACTERS.length)]);
            }
            boundary = String.format("------ClientFormBoundary%s--", b.toString());
        }
        return boundary;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.