blob: 8bfa4421ae632613d76d30d399809b269af107fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "apps.h"
#include <botan/numthry.h>
namespace {
int is_prime(int argc, char* argv[])
{
if(argc != 2 && argc != 3)
{
std::cerr << "Usage: " << argv[0] << " n <prob>\n";
return 2;
}
BigInt n(argv[1]);
size_t prob = 56;
if(argc == 3)
prob = to_u32bit(argv[2]);
AutoSeeded_RNG rng;
const bool prime = is_prime(n, rng, prob);
if(prime)
{
std::cout << n << " is prime\n";
return 0;
}
else
{
std::cout << n << " is not prime\n";
return 1;
}
}
REGISTER_APP(is_prime);
}
|