diff --git a/Aesi.h b/Aesi.h index 45e9ecc..9e993f7 100644 --- a/Aesi.h +++ b/Aesi.h @@ -1276,6 +1276,7 @@ class Aesi final { return ss; } + /** * @brief Read a number in binary from an input stream * @param Istream stream @@ -1285,20 +1286,18 @@ class Aesi final { * @note Fills empty bits with 0s on eof of the stream */ template requires (std::is_same_v || std::is_same_v) - static constexpr auto readBinary(std::basic_istream& istream, bool bigEndian = true) -> Aesi { - Aesi result {}; result.sign = Positive; - + constexpr auto readBinary(std::basic_istream& istream, bool bigEndian = true) -> void { + blocks = {}; sign = Positive; if(bigEndian) { - for(auto it = result.blocks.rbegin(); it != result.blocks.rend(); ++it) + for(auto it = blocks.rbegin(); it != blocks.rend(); ++it) if(!istream.read(reinterpret_cast(&*it), sizeof(block))) break; } else { - for(auto& tBlock: result.blocks) + for(auto& tBlock: blocks) if(!istream.read(reinterpret_cast(&tBlock), sizeof(block))) break; } - - return result; } + /** * @brief Write a number in binary to the output stream * @param Ostream stream diff --git a/test/benchmarks/measures.db b/test/benchmarks/measures.db index bc13718..cba72ac 100644 Binary files a/test/benchmarks/measures.db and b/test/benchmarks/measures.db differ diff --git a/test/operations/binary_read_write.cpp b/test/operations/binary_read_write.cpp index ce2e063..4c9737e 100644 --- a/test/operations/binary_read_write.cpp +++ b/test/operations/binary_read_write.cpp @@ -6,153 +6,153 @@ TEST(Binary, BinaryRead) { { unsigned blocks [] = { 0b10101101001111100100101100011001, 0b10011100010101101100011010011111, 0b10101111111011111111110000001010, 0b11100011100100010111011001110111, 0b00010111100000101010100101010111, 0b00101101011000010111100001011111, 0b11100001010011100011000100110010, 0b00111011011001000000101101100010, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b1010110100111110010010110001100110011100010101101100011010011111101011111110111111111100000010101110001110010001011101100111011100010111100000101010100101010111001011010110000101111000010111111110000101001110001100010011001000111011011001000000101101100010"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b1010110100111110010010110001100110011100010101101100011010011111101011111110111111111100000010101110001110010001011101100111011100010111100000101010100101010111001011010110000101111000010111111110000101001110001100010011001000111011011001000000101101100010"); } { unsigned blocks [] = { 0b01000010010011110100011111111110, 0b11010100010001111100100001010110, 0b10010101011011111001000001000101, 0b10100101101100001111101101111010, 0b10001001011001011010111010101100, 0b10111000110011110011010101010011, 0b10011101011111101100111010111111, 0b00011111011110111001010101000101, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0100001001001111010001111111111011010100010001111100100001010110100101010110111110010000010001011010010110110000111110110111101010001001011001011010111010101100101110001100111100110101010100111001110101111110110011101011111100011111011110111001010101000101"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0100001001001111010001111111111011010100010001111100100001010110100101010110111110010000010001011010010110110000111110110111101010001001011001011010111010101100101110001100111100110101010100111001110101111110110011101011111100011111011110111001010101000101"); } { unsigned blocks [] = { 0b11011010010110100100000111101101, 0b00011101110010011010100110000111, 0b10010111000001001011001000100011, 0b01011100100010100000000100101010, 0b00101010011111010110100100101111, 0b10001010101010101000100101101011, 0b00010000110100111110100100011000, 0b00101110100101001000110001011010, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b1101101001011010010000011110110100011101110010011010100110000111100101110000010010110010001000110101110010001010000000010010101000101010011111010110100100101111100010101010101010001001011010110001000011010011111010010001100000101110100101001000110001011010"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b1101101001011010010000011110110100011101110010011010100110000111100101110000010010110010001000110101110010001010000000010010101000101010011111010110100100101111100010101010101010001001011010110001000011010011111010010001100000101110100101001000110001011010"); } { unsigned blocks [] = { 0b10100101111011010010011101111111, 0b11110011100010000001101000101110, 0b10000011111100110011000000100010, 0b10110111111101011100110101110111, 0b11000000000111111111100101111101, 0b10011010011111000001001100111111, 0b01010100000101011100110101111001, 0b10010100110111111000011001110100, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b1010010111101101001001110111111111110011100010000001101000101110100000111111001100110000001000101011011111110101110011010111011111000000000111111111100101111101100110100111110000010011001111110101010000010101110011010111100110010100110111111000011001110100"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b1010010111101101001001110111111111110011100010000001101000101110100000111111001100110000001000101011011111110101110011010111011111000000000111111111100101111101100110100111110000010011001111110101010000010101110011010111100110010100110111111000011001110100"); } { unsigned blocks [] = { 0b01100111111010101110110000110010, 0b10001100110101110111010111000111, 0b00111001011001100001110110101000, 0b10010011001110000000001100011011, 0b00110100011001101010010100011110, 0b10011000110010100000100101001010, 0b11010010111001110000000100110110, 0b11111011010111110101100000001111, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0110011111101010111011000011001010001100110101110111010111000111001110010110011000011101101010001001001100111000000000110001101100110100011001101010010100011110100110001100101000001001010010101101001011100111000000010011011011111011010111110101100000001111"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0110011111101010111011000011001010001100110101110111010111000111001110010110011000011101101010001001001100111000000000110001101100110100011001101010010100011110100110001100101000001001010010101101001011100111000000010011011011111011010111110101100000001111"); } { unsigned blocks [] = { 0b10011000100110011010100101101010, 0b00100101011111100100010101110011, 0b11111001001010100110111101100100, 0b00111010110100100011000011110100, 0b00111110010101010000000010101000, 0b01101111111010101100001010101100, 0b01111000011100011111010110101000, 0b00001001000001010010011000101101, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b1001100010011001101010010110101000100101011111100100010101110011111110010010101001101111011001000011101011010010001100001111010000111110010101010000000010101000011011111110101011000010101011000111100001110001111101011010100000001001000001010010011000101101"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b1001100010011001101010010110101000100101011111100100010101110011111110010010101001101111011001000011101011010010001100001111010000111110010101010000000010101000011011111110101011000010101011000111100001110001111101011010100000001001000001010010011000101101"); } { unsigned blocks [] = { 0b00111001011011111100011000011110, 0b11000011100001001111101111111011, 0b11101010101100110100001011110001, 0b01010001110100001000001100011010, 0b00000111111101010011000000011110, 0b01111110010111110110111111001010, 0b00001011101111111100101110111000, 0b10100001100100100011110000011000, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0011100101101111110001100001111011000011100001001111101111111011111010101011001101000010111100010101000111010000100000110001101000000111111101010011000000011110011111100101111101101111110010100000101110111111110010111011100010100001100100100011110000011000"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0011100101101111110001100001111011000011100001001111101111111011111010101011001101000010111100010101000111010000100000110001101000000111111101010011000000011110011111100101111101101111110010100000101110111111110010111011100010100001100100100011110000011000"); } { unsigned blocks [] = { 0b10010101010001011010101111011000, 0b10100110100110001001000110011001, 0b10111000011100110100010010010010, 0b10011001100110011101011100110001, 0b11000101010001000000101100001110, 0b01010101101000010111101000101110, 0b11010001101111111000101010101110, 0b01011101001000110000100110000001, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b1001010101000101101010111101100010100110100110001001000110011001101110000111001101000100100100101001100110011001110101110011000111000101010001000000101100001110010101011010000101111010001011101101000110111111100010101010111001011101001000110000100110000001"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b1001010101000101101010111101100010100110100110001001000110011001101110000111001101000100100100101001100110011001110101110011000111000101010001000000101100001110010101011010000101111010001011101101000110111111100010101010111001011101001000110000100110000001"); } { unsigned blocks [] = { 0b10001010011001101010000111101010, 0b01000100101000000010011110110111, 0b10110011111100001110101100100111, 0b10111100110110001100100100001001, 0b00111001110010010110110000111001, 0b01001101110011011100110101101000, 0b01110011110000010001111111111110, 0b01101100101000110100011010010010, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b1000101001100110101000011110101001000100101000000010011110110111101100111111000011101011001001111011110011011000110010010000100100111001110010010110110000111001010011011100110111001101011010000111001111000001000111111111111001101100101000110100011010010010"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b1000101001100110101000011110101001000100101000000010011110110111101100111111000011101011001001111011110011011000110010010000100100111001110010010110110000111001010011011100110111001101011010000111001111000001000111111111111001101100101000110100011010010010"); } { unsigned blocks [] = { 0b11101100001010000111001011101010, 0b01001101110100100010111100110010, 0b00010111000100100001011001101111, 0b00000111011001101100110101010001, 0b01010010010100001110001010101111, 0b11001100011101101010100001011110, 0b01110101100001011111010011010000, 0b11111001100010010100010000111100, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b1110110000101000011100101110101001001101110100100010111100110010000101110001001000010110011011110000011101100110110011010101000101010010010100001110001010101111110011000111011010101000010111100111010110000101111101001101000011111001100010010100010000111100"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b1110110000101000011100101110101001001101110100100010111100110010000101110001001000010110011011110000011101100110110011010101000101010010010100001110001010101111110011000111011010101000010111100111010110000101111101001101000011111001100010010100010000111100"); } { unsigned blocks [] = { 0b10101101001101111101101101010011, 0b10111111110101111010111001001010, 0b00000100111000000111000100110001, 0b10100100001101101011001100110011, 0b11111000011100101110000110010000, 0b01000110101010001010111000101000, 0b01000101010100000111001011101010, 0b10010001001011001111010111110101, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b1010110100110111110110110101001110111111110101111010111001001010000001001110000001110001001100011010010000110110101100110011001111111000011100101110000110010000010001101010100010101110001010000100010101010000011100101110101010010001001011001111010111110101"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b1010110100110111110110110101001110111111110101111010111001001010000001001110000001110001001100011010010000110110101100110011001111111000011100101110000110010000010001101010100010101110001010000100010101010000011100101110101010010001001011001111010111110101"); } { unsigned blocks [] = { 0b00111100111001010010000100110010, 0b00101010110111001010110101010000, 0b10110010100000011000110100100101, 0b10111111010110101011010111010100, 0b00111011001001001100101111000000, 0b10111010011100111000001100010010, 0b11011101000100001001100110001111, 0b00010011110100110010101010010000, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0011110011100101001000010011001000101010110111001010110101010000101100101000000110001101001001011011111101011010101101011101010000111011001001001100101111000000101110100111001110000011000100101101110100010000100110011000111100010011110100110010101010010000"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0011110011100101001000010011001000101010110111001010110101010000101100101000000110001101001001011011111101011010101101011101010000111011001001001100101111000000101110100111001110000011000100101101110100010000100110011000111100010011110100110010101010010000"); } { unsigned blocks [] = { 0b00110000111000011010110000101001, 0b11110100101010101101011010000110, 0b00011101011100001001101001011110, 0b00110111111101010011010100011100, 0b01111110001000101100100100011110, 0b10100001101101111111000100101111, 0b11001000001100001001001101000111, 0b11001110101110101010010101100100, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0011000011100001101011000010100111110100101010101101011010000110000111010111000010011010010111100011011111110101001101010001110001111110001000101100100100011110101000011011011111110001001011111100100000110000100100110100011111001110101110101010010101100100"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0011000011100001101011000010100111110100101010101101011010000110000111010111000010011010010111100011011111110101001101010001110001111110001000101100100100011110101000011011011111110001001011111100100000110000100100110100011111001110101110101010010101100100"); } { unsigned blocks [] = { 0b01010010001011110101111100000010, 0b10111101011001011101100000100111, 0b01110000111101000001111111100101, 0b11000001000001010000101111101101, 0b01101000000010010101101000000101, 0b10110111110101110001100111111100, 0b00101010001001011100101000011111, 0b10000000110110001111110110110001, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0101001000101111010111110000001010111101011001011101100000100111011100001111010000011111111001011100000100000101000010111110110101101000000010010101101000000101101101111101011100011001111111000010101000100101110010100001111110000000110110001111110110110001"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0101001000101111010111110000001010111101011001011101100000100111011100001111010000011111111001011100000100000101000010111110110101101000000010010101101000000101101101111101011100011001111111000010101000100101110010100001111110000000110110001111110110110001"); } { unsigned blocks [] = { 0b10001011111101010001000100000111, 0b00110100001010000111010110110000, 0b01000101111001010011011100110110, 0b10010001111010110110100010001100, 0b10111001101001000101011110111000, 0b11110100101001000101111100001100, 0b10000010101010111000101111010010, 0b11110101111100110001000100011010, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b1000101111110101000100010000011100110100001010000111010110110000010001011110010100110111001101101001000111101011011010001000110010111001101001000101011110111000111101001010010001011111000011001000001010101011100010111101001011110101111100110001000100011010"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b1000101111110101000100010000011100110100001010000111010110110000010001011110010100110111001101101001000111101011011010001000110010111001101001000101011110111000111101001010010001011111000011001000001010101011100010111101001011110101111100110001000100011010"); } { unsigned blocks [] = { 0b10110010111011010110001100001101, 0b01101000011101011111001110101001, 0b00010000011010111011010101010000, 0b00001011101101001110000100011010, 0b01001001001101000111111000000100, 0b01010110100011110001111010101101, 0b10001110101001001000110011011010, 0b10010111001000000010110100100000, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b1011001011101101011000110000110101101000011101011111001110101001000100000110101110110101010100000000101110110100111000010001101001001001001101000111111000000100010101101000111100011110101011011000111010100100100011001101101010010111001000000010110100100000"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b1011001011101101011000110000110101101000011101011111001110101001000100000110101110110101010100000000101110110100111000010001101001001001001101000111111000000100010101101000111100011110101011011000111010100100100011001101101010010111001000000010110100100000"); } { unsigned blocks [] = { 0b01101000110100001110111101100101, 0b00001100000000100101011000110101, 0b01111100010100001010111110001110, 0b11100101001010011010101110110100, 0b10111001010010000000011000011001, 0b01000011101100100010011011110111, 0b11101101000011110011101101101010, 0b11011101000101010111101111011111, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0110100011010000111011110110010100001100000000100101011000110101011111000101000010101111100011101110010100101001101010111011010010111001010010000000011000011001010000111011001000100110111101111110110100001111001110110110101011011101000101010111101111011111"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0110100011010000111011110110010100001100000000100101011000110101011111000101000010101111100011101110010100101001101010111011010010111001010010000000011000011001010000111011001000100110111101111110110100001111001110110110101011011101000101010111101111011111"); } { unsigned blocks [] = { 0b00100110000001011001111000011111, 0b01000011111100011111101111000111, 0b01100011010101011010001100101100, 0b10001001101100000010000001011000, 0b10111000110101011001100111110101, 0b01011110110011000011101100101000, 0b10101010100101110110100110011100, 0b10001010010110001110001101100110, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0010011000000101100111100001111101000011111100011111101111000111011000110101010110100011001011001000100110110000001000000101100010111000110101011001100111110101010111101100110000111011001010001010101010010111011010011001110010001010010110001110001101100110"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0010011000000101100111100001111101000011111100011111101111000111011000110101010110100011001011001000100110110000001000000101100010111000110101011001100111110101010111101100110000111011001010001010101010010111011010011001110010001010010110001110001101100110"); } { unsigned blocks [] = { 0b00000010111110011000010000011001, 0b01100110000101011011000111101011, 0b01101010011010101001100011111010, 0b00000110010001110111100001001001, 0b10000001001101101110000000111011, 0b10111011001111000100110111010000, 0b10101011110100110110011011100001, 0b10001100101100011100011011001010, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0000001011111001100001000001100101100110000101011011000111101011011010100110101010011000111110100000011001000111011110000100100110000001001101101110000000111011101110110011110001001101110100001010101111010011011001101110000110001100101100011100011011001010"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0000001011111001100001000001100101100110000101011011000111101011011010100110101010011000111110100000011001000111011110000100100110000001001101101110000000111011101110110011110001001101110100001010101111010011011001101110000110001100101100011100011011001010"); } { unsigned blocks [] = { 0b01001010011110011000011000001001, 0b00001110111101110110100100011111, 0b00001100100011001010101000001110, 0b11110100011010101010010010011100, 0b01011011101001101010110101000100, 0b10011011011000100011001101010111, 0b01011010101001011011110111110000, 0b00101001111011000001011110001110, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0100101001111001100001100000100100001110111101110110100100011111000011001000110010101010000011101111010001101010101001001001110001011011101001101010110101000100100110110110001000110011010101110101101010100101101111011111000000101001111011000001011110001110"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0100101001111001100001100000100100001110111101110110100100011111000011001000110010101010000011101111010001101010101001001001110001011011101001101010110101000100100110110110001000110011010101110101101010100101101111011111000000101001111011000001011110001110"); } { unsigned blocks [] = { 0b01000010011101011011010111100101, 0b11111001110010000101101000010011, 0b11001010110100101000101110110111, 0b00110000101010011101001111111011, 0b11110001101100100001000000110111, 0b11011001111001101110101111101000, 0b11100101011001110101110111011100, 0b10111100100000001101101011101101, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0100001001110101101101011110010111111001110010000101101000010011110010101101001010001011101101110011000010101001110100111111101111110001101100100001000000110111110110011110011011101011111010001110010101100111010111011101110010111100100000001101101011101101"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0100001001110101101101011110010111111001110010000101101000010011110010101101001010001011101101110011000010101001110100111111101111110001101100100001000000110111110110011110011011101011111010001110010101100111010111011101110010111100100000001101101011101101"); } { unsigned blocks [] = { 0b01001101010001110011010111010101, 0b11010010000101111000101101100000, 0b01111100001111110100000101101000, 0b11101011110100111110111001000111, 0b11001001100000111101100011010001, 0b01110000100010100110001110100100, 0b11100000101111110111100000001100, 0b11111101000111101111110011110001, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0100110101000111001101011101010111010010000101111000101101100000011111000011111101000001011010001110101111010011111011100100011111001001100000111101100011010001011100001000101001100011101001001110000010111111011110000000110011111101000111101111110011110001"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0100110101000111001101011101010111010010000101111000101101100000011111000011111101000001011010001110101111010011111011100100011111001001100000111101100011010001011100001000101001100011101001001110000010111111011110000000110011111101000111101111110011110001"); } { unsigned blocks [] = { 0b01001101101100110101101110111001, 0b11100000100110011110010000100011, 0b11111111101101110110101001001000, 0b11100010010100111101101101100100, 0b00011010000011101100011001010001, 0b01101110000101111101100001001000, 0b01110010000000111101000011011100, 0b01001101011110000110101000001001, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0100110110110011010110111011100111100000100110011110010000100011111111111011011101101010010010001110001001010011110110110110010000011010000011101100011001010001011011100001011111011000010010000111001000000011110100001101110001001101011110000110101000001001"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0100110110110011010110111011100111100000100110011110010000100011111111111011011101101010010010001110001001010011110110110110010000011010000011101100011001010001011011100001011111011000010010000111001000000011110100001101110001001101011110000110101000001001"); } { unsigned blocks [] = { 0b11010100010100010011100101001100, 0b01000101011111011011011101100000, 0b11011100001111111101110000101110, 0b11000101010000000111011100100010, 0b11011011010101001111110011100111, 0b11010111111010100100011100011101, 0b11001111100111100001000111110100, 0b01000011011111111011001101110111, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b1101010001010001001110010100110001000101011111011011011101100000110111000011111111011100001011101100010101000000011101110010001011011011010101001111110011100111110101111110101001000111000111011100111110011110000100011111010001000011011111111011001101110111"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b1101010001010001001110010100110001000101011111011011011101100000110111000011111111011100001011101100010101000000011101110010001011011011010101001111110011100111110101111110101001000111000111011100111110011110000100011111010001000011011111111011001101110111"); } { unsigned blocks [] = { 0b01010010110010011100010111100101, 0b10110010100101110100010010010101, 0b00000111110000110000011001010111, 0b01010001111111011011111110001001, 0b10011001000110111010100111111001, 0b10011010101101010010111101010011, 0b01111011011110011000010100011010, 0b00010000110101000100001101011011, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b0101001011001001110001011110010110110010100101110100010010010101000001111100001100000110010101110101000111111101101111111000100110011001000110111010100111111001100110101011010100101111010100110111101101111001100001010001101000010000110101000100001101011011"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b0101001011001001110001011110010110110010100101110100010010010101000001111100001100000110010101110101000111111101101111111000100110011001000110111010100111111001100110101011010100101111010100110111101101111001100001010001101000010000110101000100001101011011"); } { unsigned blocks [] = { 0b00110011001001010101001011100100, 0b00010011011101111100110100110001, 0b11011101101010011111101011001001, 0b00101010101000001100110110001111, 0b00011100101001010100000000011110, 0b11000111100000100000100100101111, 0b11110111111010111000100001001011, 0b01000000001101110101111110100111, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0011001100100101010100101110010000010011011101111100110100110001110111011010100111111010110010010010101010100000110011011000111100011100101001010100000000011110110001111000001000001001001011111111011111101011100010000100101101000000001101110101111110100111"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0011001100100101010100101110010000010011011101111100110100110001110111011010100111111010110010010010101010100000110011011000111100011100101001010100000000011110110001111000001000001001001011111111011111101011100010000100101101000000001101110101111110100111"); } { unsigned blocks [] = { 0b10011010101111010011001010100100, 0b00001100011110001001111100010010, 0b11110100110010100111111100010001, 0b11011010011100110011100111001100, 0b00100100101000011010001011010111, 0b11110001000110011101110100100010, 0b10111010000001001111100011101001, 0b11000000110100001010011001111100, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b1001101010111101001100101010010000001100011110001001111100010010111101001100101001111111000100011101101001110011001110011100110000100100101000011010001011010111111100010001100111011101001000101011101000000100111110001110100111000000110100001010011001111100"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b1001101010111101001100101010010000001100011110001001111100010010111101001100101001111111000100011101101001110011001110011100110000100100101000011010001011010111111100010001100111011101001000101011101000000100111110001110100111000000110100001010011001111100"); } { unsigned blocks [] = { 0b00111101110011101001101111100010, 0b10001100111000110101011100111101, 0b11001011010001000110001101010111, 0b10100111111001111011000010011101, 0b01100110011011111110000110010000, 0b11110101000101100010110000011100, 0b10010000010011100010110100110110, 0b00011000100011000001010111111100, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b0011110111001110100110111110001010001100111000110101011100111101110010110100010001100011010101111010011111100111101100001001110101100110011011111110000110010000111101010001011000101100000111001001000001001110001011010011011000011000100011000001010111111100"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b0011110111001110100110111110001010001100111000110101011100111101110010110100010001100011010101111010011111100111101100001001110101100110011011111110000110010000111101010001011000101100000111001001000001001110001011010011011000011000100011000001010111111100"); } { unsigned blocks [] = { 0b10100000010010010000100100001111, 0b11100111100100111010010001111101, 0b11111100000110011000010110101100, 0b00000111001100101111101101011110, 0b00011110010100100110110111110011, 0b11001010010011110110101100001111, 0b11001111010001010000101110011011, 0b11110001011001101101111110110000, }; - std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, true), "0b1010000001001001000010010000111111100111100100111010010001111101111111000001100110000101101011000000011100110010111110110101111000011110010100100110110111110011110010100100111101101011000011111100111101000101000010111001101111110001011001101101111110110000"); + std::stringstream ss; for(auto& block: blocks) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, true); + EXPECT_EQ(a, "0b1010000001001001000010010000111111100111100100111010010001111101111111000001100110000101101011000000011100110010111110110101111000011110010100100110110111110011110010100100111101101011000011111100111101000101000010111001101111110001011001101101111110110000"); } { unsigned blocks [] = { 0b11110010100101100101010100100010, 0b10011010100011101111110111011100, 0b10110000000100110110111111100111, 0b01100000111000110100100011011011, 0b11000100001111011000011110001000, 0b10101011100100001010011101000011, 0b01101100001100110000111000000101, 0b00010010001100010100000011010010, }; - std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); - EXPECT_EQ(Aesi<256>::readBinary(ss, false), "0b1111001010010110010101010010001010011010100011101111110111011100101100000001001101101111111001110110000011100011010010001101101111000100001111011000011110001000101010111001000010100111010000110110110000110011000011100000010100010010001100010100000011010010"); + std::stringstream ss; for(auto& block: std::views::reverse(blocks)) ss.write(reinterpret_cast(&block), sizeof(unsigned)); Aesi<256> a; a.readBinary(ss, false); + EXPECT_EQ(a, "0b1111001010010110010101010010001010011010100011101111110111011100101100000001001101101111111001110110000011100011010010001101101111000100001111011000011110001000101010111001000010100111010000110110110000110011000011100000010100010010001100010100000011010010"); } }