我需要使用种子(字节数组)为我的算法生成一个 key 。此代码不起作用,因为它在不同平台上给出了 2 个不同的结果:
byte seed [] = {50,30,...};
byte result [] = new byte [20];
SecureRandom rand = new SecureRandom();
rand.setSeed(seed);
rand.nextBytes(result);
我需要在不同平台上获得相同的结果。
最佳答案
使用 SHA1PRNG 算法而不是 NativePRNG。
SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
rand.setSeed(seed);
rand.nextBytes(result);
关于java - 如何用种子生成 key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30184912/