-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInit_vec.cpp
More file actions
30 lines (24 loc) · 871 Bytes
/
Init_vec.cpp
File metadata and controls
30 lines (24 loc) · 871 Bytes
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
#include <iostream>
#include <random>
#include "Init_vec.hpp"
unsigned long long InitClass::generateRandomNumber() {
// 乱数エンジンの生成
std::random_device rd;
std::mt19937_64 gen(rd());
// 16桁のランダムな整数を生成
std::uniform_int_distribution<unsigned long long> dist(1000000000000000ULL, 9999999999999999ULL);
return dist(gen);
}
std::string InitClass::generateCommonKey() {
// 乱数エンジンの生成
std::random_device rd;
std::mt19937 gen(rd());
// 16桁のランダムな文字列を生成
const std::string charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::uniform_int_distribution<std::size_t> dist(0, charset.size() - 1);
std::string result;
for (int i = 0; i < 16; ++i) {
result += charset[dist(gen)];
}
return result;
}