title: Java encryption alternitive to hardcoded key
body: <p>I am new to encryption.</p>
  
  <p>I have looked at the javax.crypto documentation and got encryption of a file to work using this code ...</p>
  
  <pre><code>File saveFile = new File("Settings.set");
          saveFile.delete();
          FileOutputStream fout = new FileOutputStream(saveFile);
  
          //Encrypt the settings
          //Generate a key
          byte key[] = "My Encryption Key98".getBytes();
          DESKeySpec desKeySpec = new DESKeySpec(key);
          SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
          SecretKey skey = keyFactory.generateSecret(desKeySpec);
  
          //Prepare the encrypter
          Cipher ecipher = Cipher.getInstance("DES");
          ecipher.init(Cipher.ENCRYPT_MODE, skey);
          // Seal (encrypt) the object
          SealedObject so = new SealedObject(this, ecipher);
  
          ObjectOutputStream o = new ObjectOutputStream(fout);
          o.writeObject(so);
          o.close();
  </code></pre>
  
  <p>However if you were a clever hacker ( or maybe even amateur since I figured this out), all you would have to do is open the class file that contains this code, and the encryption key (My Encryption Key98) is plainly visible.</p>
  
  <p>How do you encrypt the encryption key? ...LOL...  Can you?</p>
  
  <p>Thanks for your help!</p>