@Override public boolean nextBoolean() { byte val; synchronized(_fortuna) { val = _fortuna.nextByte(); } return ((val & 0x01) != 0); }
/** * Not part of java.util.SecureRandom, but added for efficiency, since Fortuna supports it. * * @since 0.9.24 */ public byte nextByte() { synchronized(_fortuna) { return _fortuna.nextByte(); } }
/** * Pull the next numBits of random data off the fortuna instance (returning 0 * through 2^numBits-1 * * Caller must synchronize! */ protected int nextBits(int numBits) { long rv = 0; int bytes = (numBits + 7) / 8; for (int i = 0; i < bytes; i++) rv += ((_fortuna.nextByte() & 0xFF) << i*8); //rv >>>= (64-numBits); if (rv < 0) rv = 0 - rv; int off = 8*bytes - numBits; rv >>>= off; return (int)rv; }