title: Generate a DES key and use cipher for encryption
body: <p>I want to learn about cryptography with java and I found 
  <a href="https://www.cs.umd.edu/~jkatz/security/f09/lectures/JCA.pdf" rel="nofollow noreferrer">these</a> slides on the internet. On page 9 I found on an example and I tried to use it. However, the following code is not compiling. Where is the mistake? </p>
  
  <pre><code>import javax.crypto.Cipher;
  import javax.crypto.KeyGenerator;
  import javax.crypto.SecretKey;
  
  public class Gen_DESAES_key{
  
  
  byte[] message = "Hello World".getBytes();
  
  KeyGenerator keygenerator = KeyGenerator.getInstance("DES");
  SecretKey desKey = keygenerator.generateKey();
  
  Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
  desCipher.init(Cipher.ENCRYPT_MODE,deskey);
  
  byte[] encryptedMessage = desCipher.doFinal(message);
  }
  </code></pre>