prng.collector.SchedulingEntropy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SecurePRNG-core Show documentation
Show all versions of SecurePRNG-core Show documentation
The core random number generators
package prng.collector;
import prng.config.Config;
/**
* Use the amount of time between calls as a source of entropy
*
* @author Simon Greatrix
*/
public class SchedulingEntropy extends EntropyCollector {
/** Last time this was called */
private long lastTime = System.nanoTime();
/**
* Create a collector that uses scheduling accuracy to produce entropy
*
* @param config configuration for this
*/
public SchedulingEntropy(Config config) {
super(config, 50);
}
@Override
protected boolean initialise() {
return true;
}
@Override
protected void runImpl() {
long now = System.nanoTime();
long diff = now - lastTime;
lastTime = now;
setEvent((short) diff);
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy