我生成兩個密鑰:1)公鑰和2)私有密鑰,都存儲爲字節數組, 我需要這兩個鍵轉換成字符串,並將其發送到接收端和接收端將字符串轉換爲字節數組。但不知何故其轉換字符串字節數組如何關鍵的字節數組轉換爲字符串,反之亦然
編碼後賦予不同密鑰字節:
System.out.println("certificate insertionSuccessful."+certPojo.getUser_public_key()+", "+certPojo.getUser_private_key());
String str1 = new String(certPojo.getUser_public_key());
String str2 = new String(certPojo.getUser_private_key());
System.out.println("publickey===>"+str1);
System.out.println("privatekey===>"+str2);
byte[] bytes1 = str1.getBytes();
byte[] bytes2 = str2.getBytes();
System.out.println("Text [Byte Format] : " + bytes1);
System.out.println("Text [Byte Format] : " + bytes2);
I also tried using UTF-8 but nothing works
輸出:
你如何比較字節數組? – Natalia
'滿足Arrays.equals()' –