我怎样才能让 Fortuna 生成器(来自 gnu 类路径的生成器)正常工作?
由于某种原因,无论我尝试什么代码,该代码总是输出错误
Exception in thread "main" java.lang.IllegalStateException: generator not seeded
。我已在消息底部包含了我的测试代码。另外,我一直无法找到该生成器的文档。我没有使用 gnu 类路径,我只是导入了 Fortuna.java 想要的类。
public class derp {
public static void main(String[] args) throws IllegalStateException, LimitReachedException{
Fortuna rand = new Fortuna();
Map<Object,String> mp=new HashMap<Object, String>();
String derpherpderp="gafibdawhid";
String key = Crypto.MD5(derpherpderp);
byte[] key2 = key.getBytes();
mp.put(new Integer(1), key);
int five = key2.length;
rand.addRandomBytes(key2,0,five);
rand.setup(mp);
rand.addRandomBytes(key2,0,five);
System.out.println(rand.nextByte());
}
}
For some reason, no matter what code I try, this code always outputs a
Exception in thread "main" java.lang.IllegalStateException: generator not seeded
error. I have included my test code at the bottom of the message. Also, I have been unable to find documentation for this generator. And I am not using the gnu classpath, I just imported the classes that the Fortuna.java wanted.
public class derp {
public static void main(String[] args) throws IllegalStateException, LimitReachedException{
Fortuna rand = new Fortuna();
Map<Object,String> mp=new HashMap<Object, String>();
String derpherpderp="gafibdawhid";
String key = Crypto.MD5(derpherpderp);
byte[] key2 = key.getBytes();
mp.put(new Integer(1), key);
int five = key2.length;
rand.addRandomBytes(key2,0,five);
rand.setup(mp);
rand.addRandomBytes(key2,0,five);
System.out.println(rand.nextByte());
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论