编辑:抱歉发错了,下次我会更好地检查论坛位置。我选择了一个已接受的答案,我认为这认为问题已结束。感谢您的有用回复和提示!
原文:我今天需要升级到新的 Iota 钱包。它没有随机种子生成器,所以我自己构建并从 NetBeans 运行它。你能给我你的意见吗?它必须是 81 个字符长,并且包含 A 到 Z 和数字 9。没有别的。这是整个代码。
这会留下什么不安全的东西吗?从约定的角度来看,代码会更干净吗?
class SeedGenerator {
/*
This is a program to randomize a seed for Iota wallet
*/
public static void main(String[] args) {
System.out.println("*****");
int seedLength = 81;
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9"; //Only characters allowed in Iota seed are A-Z and number 9
char[] charArray = alphabet.toCharArray(); //Turn string into array of characters to be referenced by index
String[] seed = new String[seedLength];
System.out.print("Random wallet seed is: ");
for (int i = 0; i < seedLength; i++) {
Random newRandomNumber = new Random();
int seedIndex = newRandomNumber.nextInt(alphabet.length()); //This is an array of index numbers to pull from charArray
// System.out.print(seedIndex + " "); //Used for testing the random character index range
seed[i] += charArray[seedIndex];
System.out.print(charArray[seedIndex] + "");
}
System.out.println();
System.out.println("*****");
}
}