title: How to store the autogenerated secret key in a text file,
body: <p>How do i store the generated key a text file at a particular location. I am trying to store the key and decrypt when required for the particular user. I am using two different java class one for encrypting and decryption, i need the store the particular key use to encrypt the user else i am getting illegal block size, not able to decrypt the data in the file, the data gets deleted.</p>
  
  <pre><code>SecretKey secKey = keyGen.generateKey();
  
  System.out.println(secKey);
  String KeyStore = "C:\\keystore.txt";
  FileOutputStream fout=new FileOutputStream(KeyStore);  
  
  
  byte[] b=secKey.getBytes();//this is not working for me 
  fout.write(b);  
  fout.close(); 
  </code></pre>
  
  <p>help me out this there another option to store the key for a particular use</p>