import javax.crypto.*; import javax.crypto.spec.*; import java.io.*; public class DESKrypt3{ public static void main(String argumendid[]) throws Exception{ byte[] avatekstibaidid=(loeRida("Teade:")+" ").getBytes(); byte[] sool=new byte[8]; for(int i=0; i<8; i++){ sool[i]=(byte)0xFF; } int segamiskordadearv=10; SecretKey voti=SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret( new PBEKeySpec(loeRida("Parool:").toCharArray()) ); Cipher kodeerija=Cipher.getInstance("PBEWithMD5AndDES"); kodeerija.init(Cipher.ENCRYPT_MODE, voti, new PBEParameterSpec(sool, segamiskordadearv)); CipherOutputStream salavaljundvoog=new CipherOutputStream( new FileOutputStream("DES3.dat"), kodeerija ); salavaljundvoog.write(avatekstibaidid); salavaljundvoog.close(); } public static String loeRida(String kysimus) throws IOException{ System.out.println(kysimus); return new BufferedReader(new InputStreamReader(System.in)).readLine(); } }