[問題] cipherOutput/InputStream 要如何用 Socket 傳收?
程式主要是..
Client:
製造 Key,加密訊息後,透過 Socket 傳給 Server。
程式碼節錄:
String message = "PTT java";
Socket s = new Socket(host, port);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key);
CipherOutputStream cipherout
= new CipherOutputStream(s.getOutputStream(),cipher);
cipherout.write(message.getBytes());
-----
可是到這邊我就不知道要怎麼讓 Socket 傳過去。
Google 到的做法:
PrintWriter outto = new PrintWriter(s.getOutputStream(), true);
outto.println(這邊放要傳的東西);
是要這樣傳嗎?但我不知道如何結合兩者,還是說這樣就已經傳過去?
希望有人可以解惑,謝謝!
--
如果描述不夠清楚會再補充,我知道我是來求教(救?!)不是來算命的!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 128.237.226.10
推
12/10 18:41, , 1F
12/10 18:41, 1F
→
12/11 00:42, , 2F
12/11 00:42, 2F
→
12/11 00:50, , 3F
12/11 00:50, 3F
→
12/11 01:36, , 4F
12/11 01:36, 4F