diff options
Diffstat (limited to 'doc/examples/dsa_kgen.cpp')
-rw-r--r-- | doc/examples/dsa_kgen.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/doc/examples/dsa_kgen.cpp b/doc/examples/dsa_kgen.cpp index eb3a00393..2e42c06b7 100644 --- a/doc/examples/dsa_kgen.cpp +++ b/doc/examples/dsa_kgen.cpp @@ -25,14 +25,12 @@ using namespace Botan; int main(int argc, char* argv[]) { - if(argc != 2) + if(argc != 1 && argc != 2) { - std::cout << "Usage: " << argv[0] << " passphrase" << std::endl; + std::cout << "Usage: " << argv[0] << " [passphrase]" << std::endl; return 1; } - std::string passphrase(argv[1]); - std::ofstream priv("dsapriv.pem"); std::ofstream pub("dsapub.pem"); if(!priv || !pub) @@ -47,7 +45,10 @@ int main(int argc, char* argv[]) DSA_PrivateKey key(DL_Group("dsa/jce/1024")); pub << X509::PEM_encode(key); - priv << PKCS8::PEM_encode(key, passphrase); + if(argc == 1) + priv << PKCS8::PEM_encode(key); + else + priv << PKCS8::PEM_encode(key, argv[1]); } catch(std::exception& e) { |