diff options
author | Peter Palfrader <peter@palfrader.org> | 2003-10-19 15:08:35 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2003-10-19 15:08:35 +0000 |
commit | a4c0d3d6d878da55435cb9d9cc8cff6199644199 (patch) | |
tree | e066aabfb7a143cd39c3740b4aedd701df5ac758 /src/org/noreply/fancydress/crypto/CryptoPrimitives.java | |
parent | 46a03a3ea3c26a65e4428bc9de036a01487aeda3 (diff) |
Support random path creation
Diffstat (limited to 'src/org/noreply/fancydress/crypto/CryptoPrimitives.java')
-rw-r--r-- | src/org/noreply/fancydress/crypto/CryptoPrimitives.java | 19 |
1 files changed, 19 insertions, 0 deletions
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 @@ -66,6 +66,25 @@ public class CryptoPrimitives { return(result); } /** + * Get a random value from the normal distrubution with mean <code>u</code> and standard deviation <code>s</code> + * + * @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 <code>n</code> octets of zeroes. * * @param n number of octets |