From a4c0d3d6d878da55435cb9d9cc8cff6199644199 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 19 Oct 2003 15:08:35 +0000 Subject: Support random path creation --- .../noreply/fancydress/crypto/CryptoPrimitives.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/org/noreply/fancydress/crypto/CryptoPrimitives.java') diff --git a/src/org/noreply/fancydress/crypto/CryptoPrimitives.java b/src/org/noreply/fancydress/crypto/CryptoPrimitives.java index 820dbcb..d9b9884 100644 --- a/src/org/noreply/fancydress/crypto/CryptoPrimitives.java +++ b/src/org/noreply/fancydress/crypto/CryptoPrimitives.java @@ -65,6 +65,25 @@ public class CryptoPrimitives { secureRandom.nextBytes(result); return(result); } + /** + * Get a random value from the normal distrubution with mean u and standard deviation s + * + * @param u mean or the normal distribution + * @param s standard deviation of the normal distribution + * @return a random value from given the normal distrubution + */ + public static double normal(double m, double s) { + return secureRandom.nextGaussian() * s + m; + } + /** + * Return a uniformly distributed int value between 0 (inclusive) and the specified value (exclusive). + * + * @param n the bound on the random number to be returned. Must be positive. + * @return a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive). + */ + public static int randInt(int n) { + return secureRandom.nextInt(n); + } /** * Get n octets of zeroes. * -- cgit v1.2.3