import javax.crypto.*; import javax.crypto.spec.*; import java.io.*; public class DESKrypt2{ public static void main(String argumendid[]) throws Exception{ byte[] avatekstibaidid="Juku tuli kooli. ".getBytes(); byte[] votmebaidid=new byte[8]; for(int i=0; i<8; i++){ votmebaidid[i]=(byte)0xFF; } SecretKey voti=SecretKeyFactory.getInstance("DES").generateSecret( new DESKeySpec(votmebaidid) ); Cipher kodeerija=Cipher.getInstance("DES"); kodeerija.init(Cipher.ENCRYPT_MODE, voti); CipherOutputStream salavaljundvoog=new CipherOutputStream( new FileOutputStream("DES2.dat"), kodeerija ); salavaljundvoog.write(avatekstibaidid); salavaljundvoog.close(); } }