📄 f5random.java
字号:
package crypt;
import sun.security.provider.SecureRandom;
public class F5Random {
private SecureRandom random=null;
private byte[] b=null;
public F5Random(byte[] password) {
random = new SecureRandom();
random.engineSetSeed(password);
b = new byte[1];
}
// get a random integer 0 ... (maxValue-1)
public int getNextValue(int maxValue) {
int retVal = getNextByte()
| (getNextByte() << 8)
| (getNextByte() << 16)
| (getNextByte() << 24);
retVal %= maxValue;
if (retVal<0)
retVal += maxValue;
return retVal;
}
// get a random byte
public int getNextByte() {
random.engineNextBytes(b);
return b[0];
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -