code: private String toPEM() {
  
          byte[] data = (this.keyData == null) ? this.encodedKey : Base64.encode(this.keyData);
  
          String header = HEADER;
  
          if (isEncrypted()) {
              StringBuffer buf = new StringBuffer(header);
              buf.append(PEMUtil.LINE_SEP);
              buf.append("Proc-Type: 4,ENCRYPTED");
              buf.append(PEMUtil.LINE_SEP);
              buf.append("DEK-Info: ").append(this.encAlgStr);
              buf.append(",").append(PEMUtil.toHex(initializationVector.getIV()));
              buf.append(PEMUtil.LINE_SEP);
              header = buf.toString();
          }
  
          ByteArrayOutputStream out = new ByteArrayOutputStream();
  
          try {
              PEMUtil.writeBase64(out,
                      header,
                      data,
                      "-----END RSA PRIVATE KEY-----");
          } catch (IOException e) {
              // JGLOBUS-91
              throw new RuntimeException("Unexpected error", e);
          }
  
          return new String(out.toByteArray());
      }
docs: /*
  Converts to PEM encoding.
  Assumes keyData is initialized.