summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/crypto/CryptoPrimitives.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/noreply/fancydress/crypto/CryptoPrimitives.java')
-rw-r--r--src/org/noreply/fancydress/crypto/CryptoPrimitives.java19
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