title: How to use passphrase for RSAPrivateKey in JAVA?
body: <p>I encrypt and decrypt with RSA 2048 keys. But for additional security I need to use passphrase for RSAPrivateKey with a AES 128 method.</p>
  
  <p>I can generate this keys, but I don't know how to use them in <strong>JAVA</strong>.</p>
  
  <p>In my code I initialize private (witout passphrase) key (public is the same):</p>
  
  <pre><code>String PRIVATE_KEY_FILE_RSA = "src/pri.der";
  File privKeyFile = new File(PRIVATE_KEY_FILE_RSA);
  
  // read private key DER file
  DataInputStream dis = new DataInputStream(new FileInputStream(privKeyFile));
  byte[] privKeyBytes = new byte[(int) privKeyFile.length()];
  dis.read(privKeyBytes);
  dis.close();
  KeyFactory keyFactory = KeyFactory.getInstance("RSA");
  
  // decode private key
  PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(privKeyBytes);
  RSAPrivateKey privKey =(RSAPrivatKey) keyFactory.generatePublic(pubSpec);
  </code></pre>
  
  <p>And use:</p>
  
  <pre><code>Algorithm algorithm = Algorithm.RSA256(pubKey, privKey);
  ...
  </code></pre>
  
  <p>I need for any information or examples how to enter there passphrase.</p>