hi. I'm KOREAN student. I want to know java of security. I'm not good at English. I'm sorry. this is my java source. Please. let me know why ... Exception? ///////// server.java package crypto; import java.net.ServerSocket; import java.net.Socket; import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; import java.io.*; public class Server extends Thread{ private ServerSocket ss; private Socket cs; private DataInputStream dis; private static String algorithm = "DESede"; public Server() throws IOException{ try { ss = new ServerSocket(8080); System.out.println("Server Ready."); cs = ss.accept(); System.out.println("접속자 : " + cs.toString()); dis = new DataInputStream(cs.getInputStream()); this.start(); }catch(IOException ee) { System.err.println("can not start Server."); System.exit(0); } } public void run(){ byte buf[] = new byte[128]; while(true){ try{ dis.read(buf); //byte buf[] = new byte[dis.read(buff)]; //buf = buff; System.out.println("receive : " + asHex(buf)); ObjectInputStream ois = new ObjectInputStream(new FileInputStream("DESede")); Key key = (Key)ois.readObject(); ois.close(); Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, key); byte[] recoveredBytes = cipher.doFinal(buf); String recovered = new String(recoveredBytes, "UTF8"); System.out.println("recovered message : " + recovered); }catch(Exception ie){ System.out.println("Exception : "+ie.getMessage()); } } } public static String asHex (byte buf[]) { StringBuffer strbuf = new StringBuffer(buf.length * 2); int i; for (i = 0; i < buf.length; i++) { if (((int) buf[i] & 0xff) < 0x10) strbuf.append("0"); strbuf.append(Long.toString((int) buf[i] & 0xff, 16)); } return strbuf.toString(); } public static void main(String[] args) throws Exception { Server s = new Server(); } } //////////////// client.java package crypto; import java.io.*; import java.net.Socket; import java.security.InvalidKeyException; import java.security.Key; import java.security.NoSuchAlgorithmException; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public class Client extends Thread{ private Socket soc; private OutputStream dos; public Client(){ try{ soc = new Socket("127.0.0.1", 8080); dos = new DataOutputStream(soc.getOutputStream()); System.out.println("success connection."); this.start(); }catch(IOException ie){ System.out.println("Exception : "+ie.getMessage()); } } public void run(){ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); byte encrypted[] = new byte[128]; while(true){ try { System.out.print("Input Message :"); String msg = in.readLine(); //encrypt(msg, encrypted); /* KeyGenerator keyGenerator = KeyGenerator.getInstance("DESede"); keyGenerator.init(168); // 키의 크기를 168비트로 초기화 Key key = keyGenerator.generateKey(); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("DESede")); oos.writeObject(key); oos.flush(); oos.close(); */ ObjectInputStream ois = new ObjectInputStream(new FileInputStream("DESede")); Key key = (Key)ois.readObject(); Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key); byte[] inputBytes = msg.getBytes("UTF8"); encrypted = cipher.doFinal(inputBytes); //System.out.println(asHex(encrypted)); dos.write(encrypted); dos.flush(); } catch (Exception e) { System.out.println("Exception : "+e.getMessage()); } } } public static String asHex (byte buf[]) { StringBuffer strbuf = new StringBuffer(buf.length * 2); int i; for (i = 0; i < buf.length; i++) { if (((int) buf[i] & 0xff) < 0x10) strbuf.append("0"); strbuf.append(Long.toString((int) buf[i] & 0xff, 16)); } return strbuf.toString(); } public static void main(String[] args) throws Exception { Client c = new Client(); } } /////////////////////////////////////////////// when run this code ... "Exception : Given final block not properly padded" what's the problem? I'm waiting until you comment.