Я пытаюсь сгенерировать случайный ключ с SecureRandom, но у меня возникают проблемы при помещении вывода в байтовый массив.Он не распознает выходные данные SecureRandom.
public static String byteToHex(byte[] hash) {
StringBuilder sb = new StringBuilder(hash.length * 2);
for(byte b: hash) {
sb.append(String.format("%02x", b));
}
return sb.toString();
}
SecureRandom r = new SecureRandom();
byte a[] = new byte[16];
r.nextBytes(a);
Я жестко закодировал выходные данные в байтовом массиве:
byte[] k = {ac,1d,71,c8,96,bd,f7,d5,03,38,bc,46,a2,b4,f1,a8};
Полученная ошибка:
Multiple markers at this line
- a2 cannot be resolved to a variable
- bd cannot be resolved to a variable
- d5 cannot be resolved to a variable
- b4 cannot be resolved to a variable
- c8 cannot be resolved to a variable
- f7 cannot be resolved to a variable
- a8 cannot be resolved to a variable
- f1 cannot be resolved to a variable
- Type mismatch: cannot convert from double
to byte
- ac cannot be resolved to a variable
- bc cannot be resolved to a variable
- Type mismatch: cannot convert from double
to byte
Я хочу использовать его в качестве ключа для шифрования сообщения с помощью AES