HI how would I use program options to accept multiple input.
Example I have a diffieHellmanKeyExchange program running through command
prompt.
// begin main program
#include <iostream>
#include
#include
#include "cppdef/BitOperation.cpp"
#include "cppdef/mathfunc.cpp"
#include "cppdef/IsPrime.cpp"
#include "cppdef/DiffieHellman.cpp"
#include
#include
int main( int ac, char* av[] )
{
namespace po = boost::program_options;
po::options_description desc("Allowed options");
boost::tuple key_pair;
desc.add_options()
("generate", "generates a pair of key")
("secert", po::value(&key_pair), "creates the share secret key");
po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm);
po::notify(vm);
if (vm.count("generate"))
{
BigInteger my_prime =
encryptcpw::random_prime<BigInteger>(&algocpw::Miller_Rabin<BigInteger>,
10);
std::cout << "my prime: " << my_prime << "\n";
boost::tuple
pare(encryptcpw::dh_init<BigInteger>(
my_prime
));
std::cout << "pair of generated number: " << pare << "\n";
}
if (vm.count("secert"))
{
const BigInteger p(
encryptcpw::random_prime<BigInteger>(&algocpw::Miller_Rabin<BigInteger>,
10));
std::cout << encryptcpw::dh_secret<BigInteger>(
p,
boost::tuples::get<0>(key_pair),
boost::tuples::get<1>(key_pair));
}
}
// end program
The thing compiles but when I do DiffieHellman.exe --secert 817 697
I get this error.
C:\CPW\cs_classes>DiffieHellmanEncrypt --secert 817 697
terminate called after throwing an instance of
'boost::program_options::invalid_
option_value'
what(): in option 'secert': invalid option value '817'
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.