Package java.security

Examples of java.security.SecureRandom.nextDouble()


          throw new RuntimeException(e);
        }

        for (int i = 0; i < iterations; i++)
        {
          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);
View Full Code Here


        if (lower >= upper) {
            throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
                                                lower, upper, false);
        }
        SecureRandom sec = getSecRan();
        double r = sec.nextDouble();
        double scaled = r * upper + (1.0 - r) * lower + r;
        return (int)FastMath.floor(scaled);
    }

    /** {@inheritDoc} */
 
View Full Code Here

        if (lower >= upper) {
            throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
                                                lower, upper, false);
        }
        SecureRandom sec = getSecRan();
        double r = sec.nextDouble();
        double scaled = r * upper + (1.0 - r) * lower + r;
        return (long)FastMath.floor(scaled);
    }

    /**
 
View Full Code Here

        if (lower >= upper) {
            throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
                                                lower, upper, false);
        }
        SecureRandom sec = getSecRan();
        return lower + (int) (sec.nextDouble() * (upper - lower + 1));
    }

    /**
     * Generate a random long value uniformly distributed between
     * <code>lower</code> and <code>upper</code>, inclusive. This algorithm uses
View Full Code Here

        if (lower >= upper) {
            throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
                                                lower, upper, false);
        }
        SecureRandom sec = getSecRan();
        return lower + (long) (sec.nextDouble() * (upper - lower + 1));
    }

    /**
     * {@inheritDoc}
     * <p>
 
View Full Code Here

          throw new RuntimeException(e);
        }

        for (int i = 0; i < iterations; i++)
        {
          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);
View Full Code Here

        final String letters = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ0123456789";

        String pw = "";
        for (int i = 0; i < tokenLength; i++) {
            pw += letters.charAt((int) (random.nextDouble() * letters.length()));
        }
        return pw;
    }
}
View Full Code Here

          if (lower >= upper) {
              throw new IllegalArgumentException
                ("lower bound must be < upper bound");
          }
          SecureRandom sec = getSecRan();
          return lower + (int) (sec.nextDouble() * (upper - lower + 1));
    }

    /**
     * Generate a random long value uniformly distributed between
     * <code>lower</code> and <code>upper</code>, inclusive.  This algorithm
View Full Code Here

        if (lower >= upper) {
            throw new IllegalArgumentException
            ("lower bound must be < upper bound");
        }
        SecureRandom sec = getSecRan();
        return lower + (long) (sec.nextDouble() * (upper - lower + 1));
    }

    /**
     * Generates a random long value from the Poisson distribution with the
     * given mean.
View Full Code Here

          throw new RuntimeException(e);
        }

        for (int i = 0; i < iterations; i++)
        {
          String key = "abc" + (rnd.nextDouble() * iterations);
          keys.add(key);
          map.put(key, new BufferedWebResponse(null));

          String key2 = keys.get(rnd.nextInt(keys.size() - 1));
          map.remove(key2);
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.