-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtune_lfsr.cpp
More file actions
70 lines (49 loc) · 1.99 KB
/
Copy pathtune_lfsr.cpp
File metadata and controls
70 lines (49 loc) · 1.99 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <lfsr.hpp>
#include <test_detail.hpp>
#include <filesystem>
#include <fstream>
namespace fs = std::filesystem;
using tap_list = lfsr::tap_list<0, 17, 20>;
auto run_galois(std::vector<std::uint8_t> const & to_scramble)
{
using lfsr_type = detail::feedthrough_galois_from_list_t<tap_list>;
auto lfsr = lfsr_type{};
auto scrambled = std::vector<std::uint8_t>{};
lfsr.scramble_range(std::begin(to_scramble),
std::end(to_scramble),
std::back_inserter(scrambled));
auto out = std::fstream{"scrambled.galois.bin", std::ios::out | std::ios::binary};
out.write(reinterpret_cast<char const *>(scrambled.data()), scrambled.size());
}
auto run_fibonacci(std::vector<std::uint8_t> const & to_scramble)
{
using lfsr_type = detail::feedthrough_fibonacci_from_list_t<tap_list>;
auto lfsr = lfsr_type{};
auto scrambled = std::vector<std::uint8_t>{};
lfsr.scramble_range(std::begin(to_scramble),
std::end(to_scramble),
std::back_inserter(scrambled));
auto out = std::fstream{"scrambled.fibonacci.bin", std::ios::out | std::ios::binary};
out.write(reinterpret_cast<char const *>(scrambled.data()), scrambled.size());
}
auto run_fibonacci_bulk(std::vector<std::uint8_t> const & to_scramble)
{
using lfsr_type = detail::feedthrough_fibonacci_bulk_from_list_t<tap_list>;
auto lfsr = lfsr_type{};
auto scrambled = std::vector<std::uint8_t>{};
lfsr.scramble_range(std::begin(to_scramble),
std::end(to_scramble),
std::back_inserter(scrambled));
auto out = std::fstream{"scrambled.fibonaccibulk.bin", std::ios::out | std::ios::binary};
out.write(reinterpret_cast<char const *>(scrambled.data()), scrambled.size());
}
auto main() -> int
{
auto to_scramble = std::vector<std::uint8_t>{};
for (auto ii = 0; ii != 1024 * 1024 * 100; ++ii) {
to_scramble.push_back(ii);
}
run_fibonacci(to_scramble);
run_galois(to_scramble);
run_fibonacci_bulk(to_scramble);
}