-2
class By
{
public static void main(String args[]) throws InterruptedException {
String key = "Hello world";// plaintext
byte[] x = key.getBytes();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < x.length; i++) {
int b = (int) x[i];
sb.append(Integer.toHexString(b));
}
System.out.println(sb.toString());
}
}
This program output is: 48656c6c6f20776f726c64
I need my output to be a 4-by-4 matrix as such:
1st row is:: 48 6f 72 00
2nd row is:: 65 20 6c 00
3rd row is:: 6c 77 64 00
4th row is:: 6c 6f 00 00
Wie schreibe ich Code dafür in Java? Bitte zeigen Sie mir den Code, um meine benötigte Ausgabe zu bekommen.Wie formatiere ich meine Ausgabe als 4-by-4-Matrix?
Dieselbe Frage buchstäblich in der Lage sein, wurde . https://stackoverflow.com/questions/37999956/how-to-get-hexadecimal-values-from-string-and-form-a-4-by-4-matrix. – bcsb1001
Ich habe gerade gesehen. Aber niemand gab den Code für diese Frage. – devi
Die vorherige Frage wurde gestellt und richtig formatiert .. jetzt ist es zurück zu 0 – Sid