title: Converted SecretKey into bytes, how to convert it back to a SecretKey?
body: <p>I convert the secretkey into bytes with following code</p>
  
  <pre><code>SecretKey key = KeyGenerator.getInstance("DES").generateKey();
  byte[] bkey=key.getEncoded();
  </code></pre>
  
  <p>Now how do I get the key from <code>bkey</code>? I tried:</p>
  
  <pre><code>SecretKeySpec secretkey = new SecretKeySpec(bkey,"DES");   
  SecretKeyFactory sfkey = SecretKeyFactory.getInstance("DES");
  SecretKey skey = sfkey.generateSecret(secretkey);
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Error during Exception java.security.spec.InvalidKeySpecException: Inappropriate key specification
  </code></pre>