title: How to store a key pair inside a variable so that it will not change
body: <p>How do I get this key pair out and store it so that it won't change and I will be able to use the same keypair to encrypt and decrypt  in separate applications ?  I am encrypting a string eg ("1234A") with the public key from this key pair and storing it into a database. For the decrypt part, I am getting the encrypted string out from the database and decrypting it using the private key from the same keypair.</p>
  
  <pre><code>public static KeyPair generateKey () throws NoSuchAlgorithmException
  {                    
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance ("RSA");      
      keyGen.initialize(1024);         
      KeyPair key = keyGen.generateKeyPair();        
      return key;    
  }
  </code></pre>