code: @Override
    public Msg genKeys() {
      final Msg infoLines = new Msg();
  
      try {
        final PKITools pki = new PKITools();
  
        if (getPrivKeyFileName() == null) {
          infoLines.add("Must provide a -privkey <file> parameter");
          return infoLines;
        }
  
        if (getPublicKeyFileName() == null) {
          infoLines.add("Must provide a -pubkey <file> parameter");
          return infoLines;
        }
  
        final PKITools.RSAKeys keys =
                pki.genRSAKeysIntoFiles(getPrivKeyFileName(),
                                        getPublicKeyFileName(),
                                        true);
        if (keys == null) {
          infoLines.add("Generation of keys failed");
          return infoLines;
        }
  
        // Now try the keys on the test text.
  
        final int numKeys = pki.countKeys(getPrivKeyFileName());
  
        //if (debug) {
        //  infoLines.add("Number of keys: " + numKeys);
        //}
  
        infoLines.add("test with---->" + testText);
        final String etext = pki.encryptWithKeyFile(getPublicKeyFileName(),
                                                    testText, numKeys - 1);
        infoLines.add("encrypts to-->" + etext);
        final String detext = pki.decryptWithKeyFile(getPrivKeyFileName(),
                                                     etext, numKeys - 1);
        infoLines.add("decrypts to-->" + detext);
  
        if (!testText.equals(detext)) {
          infoLines.add("Validity check failed: encrypt/decrypt failure");
        } else {
          infoLines.add("");
          infoLines.add("Validity check succeeded");
        }
      } catch (final Throwable t) {
        error(t);
        infoLines.add("Exception - check logs: " + t.getMessage());
      }
  
      return infoLines;
    }
docs: /* ========================================================================
  Operations
  ========================================================================