This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "EasyBigNum.h" | |
#include <iomanip> | |
const unsigned rsa_bits = 1024; | |
struct rsa_info{ | |
EasyBigNum p1, p2, n, totient, e, d; | |
}; | |
EasyBigNum generate_rsa_prime(std::mt19937 &source, unsigned rsa_bits) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdint> | |
class Crc32{ | |
std::uint32_t crc32; | |
static std::uint32_t lookup[]; | |
public: | |
Crc32(){ | |
this->clear(); | |
} | |
void clear(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
bool is_prime(unsigned n, unsigned i){ | |
if (i * i >= n) | |
return true; | |
if (n % i == 0) | |
return false; | |
return is_prime(n, i + 2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Returns an integer in [0;max], where max <= RAND_MAX | |
int unbiased_rand(int max){ | |
const int rand_max = RAND_MAX - (RAND_MAX + 1) % (max + 1); | |
int r; | |
do | |
r = rand(); | |
while (r > rand_max); | |
return r % (max + 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <queue> | |
#include <iomanip> | |
#include <cmath> | |
#include <algorithm> | |
#include <sstream> | |
#include <limits> | |
template <typename Float> | |
struct float_info{}; |
NewerOlder