Documentation for d4962c3032

This commit is contained in:
realstealthninja
2025-08-14 04:29:32 +00:00
parent 67d95bf85f
commit e364889a34
986 changed files with 1471 additions and 1483 deletions

View File

@@ -192,19 +192,19 @@ The matrix generation algorithm is very rudimentary and does not guarantee an in
</div><div class="memdoc">
<p>Main function </p>
<p class="definition">Definition at line <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html#l00533">533</a> of file <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html">hill_cipher.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 533</span> {</div>
<div class="line"><span class="lineno"> 534</span> std::srand(std::time(<span class="keyword">nullptr</span>));</div>
<div class="line"><span class="lineno"> 535</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Key dictionary: (&quot;</span> &lt;&lt; std::strlen(<a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">ciphers::STRKEY</a>) &lt;&lt; <span class="stringliteral">&quot;)\n\t&quot;</span></div>
<div class="line"><span class="lineno"> 536</span> &lt;&lt; <a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">ciphers::STRKEY</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 537</span> </div>
<div class="line"><span class="lineno"> 538</span> std::string text = <span class="stringliteral">&quot;This is a simple text with numb3r5 and exclamat!0n.&quot;</span>;</div>
<div class="line"><span class="lineno"> 539</span> </div>
<div class="line"><span class="lineno"> 540</span> <a class="code hl_function" href="../../d3/dae/dsu__path__compression_8cpp.html#ae7880ce913f3058a35ff106d5be9e243">test1</a>(text);</div>
<div class="line"><span class="lineno"> 541</span> <a class="code hl_function" href="../../d3/dae/dsu__path__compression_8cpp.html#a45d94ead4cf4e1ff9f87c38bc99f59ae">test2</a>(text);</div>
<div class="line"><span class="lineno"> 542</span> </div>
<div class="line"><span class="lineno"> 543</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 544</span>}</div>
<p class="definition">Definition at line <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html#l00532">532</a> of file <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html">hill_cipher.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 532</span> {</div>
<div class="line"><span class="lineno"> 533</span> std::srand(std::time(<span class="keyword">nullptr</span>));</div>
<div class="line"><span class="lineno"> 534</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Key dictionary: (&quot;</span> &lt;&lt; std::strlen(<a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">ciphers::STRKEY</a>) &lt;&lt; <span class="stringliteral">&quot;)\n\t&quot;</span></div>
<div class="line"><span class="lineno"> 535</span> &lt;&lt; <a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">ciphers::STRKEY</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 536</span> </div>
<div class="line"><span class="lineno"> 537</span> std::string text = <span class="stringliteral">&quot;This is a simple text with numb3r5 and exclamat!0n.&quot;</span>;</div>
<div class="line"><span class="lineno"> 538</span> </div>
<div class="line"><span class="lineno"> 539</span> <a class="code hl_function" href="../../d3/dae/dsu__path__compression_8cpp.html#ae7880ce913f3058a35ff106d5be9e243">test1</a>(text);</div>
<div class="line"><span class="lineno"> 540</span> <a class="code hl_function" href="../../d3/dae/dsu__path__compression_8cpp.html#a45d94ead4cf4e1ff9f87c38bc99f59ae">test2</a>(text);</div>
<div class="line"><span class="lineno"> 541</span> </div>
<div class="line"><span class="lineno"> 542</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 543</span>}</div>
<div class="ttc" id="adsu__path__compression_8cpp_html_a45d94ead4cf4e1ff9f87c38bc99f59ae"><div class="ttname"><a href="../../d3/dae/dsu__path__compression_8cpp.html#a45d94ead4cf4e1ff9f87c38bc99f59ae">test2</a></div><div class="ttdeci">static void test2()</div><div class="ttdoc">Self-implementations, 2nd test.</div><div class="ttdef"><b>Definition</b> <a href="../../d3/dae/dsu__path__compression_8cpp_source.html#l00187">dsu_path_compression.cpp:187</a></div></div>
<div class="ttc" id="adsu__path__compression_8cpp_html_ae7880ce913f3058a35ff106d5be9e243"><div class="ttname"><a href="../../d3/dae/dsu__path__compression_8cpp.html#ae7880ce913f3058a35ff106d5be9e243">test1</a></div><div class="ttdeci">static void test1()</div><div class="ttdoc">Self-test implementations, 1st test.</div><div class="ttdef"><b>Definition</b> <a href="../../d3/dae/dsu__path__compression_8cpp_source.html#l00170">dsu_path_compression.cpp:170</a></div></div>
<div class="ttc" id="anamespaceciphers_html_ab9aec0ccf4b6809f652bb540be87c216"><div class="ttname"><a href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">ciphers::STRKEY</a></div><div class="ttdeci">static const char * STRKEY</div><div class="ttdef"><b>Definition</b> <a href="../../d7/db9/hill__cipher_8cpp_source.html#l00074">hill_cipher.cpp:74</a></div></div>
@@ -281,39 +281,39 @@ template&lt;typename T&gt; </div>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html#l00471">471</a> of file <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html">hill_cipher.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 471</span> {</div>
<div class="line"><span class="lineno"> 472</span> <span class="comment">// std::string text = &quot;Hello world!&quot;;</span></div>
<div class="line"><span class="lineno"> 473</span> std::cout &lt;&lt; <span class="stringliteral">&quot;======Test 1 (3x3 key) ======\nOriginal text:\n\t&quot;</span> &lt;&lt; text</div>
<div class="line"><span class="lineno"> 474</span> &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 475</span> </div>
<div class="line"><span class="lineno"> 476</span> std::pair&lt;matrix&lt;int&gt;, <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a>&gt; p =</div>
<div class="line"><span class="lineno"> 477</span> <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">ciphers::HillCipher::generate_keys</a>(3, 0, 100);</div>
<div class="line"><span class="lineno"> 478</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> ekey = p.first;</div>
<div class="line"><span class="lineno"> 479</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> dkey = p.second;</div>
<div class="line"><span class="lineno"> 480</span> </div>
<div class="line"><span class="lineno"> 481</span> <span class="comment">// matrix&lt;int&gt; ekey = {{22, 28, 25}, {5, 26, 15}, {14, 18, 9}};</span></div>
<div class="line"><span class="lineno"> 482</span> <span class="comment">// std::cout &lt;&lt; &quot;Encryption key: \n&quot; &lt;&lt; ekey;</span></div>
<div class="line"><span class="lineno"> 483</span> std::string gibberish = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">ciphers::HillCipher::encrypt_text</a>(text, ekey);</div>
<div class="line"><span class="lineno"> 484</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Encrypted text:\n\t&quot;</span> &lt;&lt; gibberish &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 485</span> </div>
<div class="line"><span class="lineno"> 486</span> <span class="comment">// matrix&lt;int&gt; dkey = ciphers::HillCipher::generate_decryption_key(ekey);</span></div>
<div class="line"><span class="lineno"> 487</span> <span class="comment">// std::cout &lt;&lt; &quot;Decryption key: \n&quot; &lt;&lt; dkey;</span></div>
<div class="line"><span class="lineno"> 488</span> std::string txt_back = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b">ciphers::HillCipher::decrypt_text</a>(gibberish, dkey);</div>
<div class="line"><span class="lineno"> 489</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Reconstruct text:\n\t&quot;</span> &lt;&lt; txt_back &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 490</span> </div>
<div class="line"><span class="lineno"> 491</span> std::ofstream out_file(<span class="stringliteral">&quot;hill_cipher_test1.txt&quot;</span>);</div>
<div class="line"><span class="lineno"> 492</span> out_file &lt;&lt; <span class="stringliteral">&quot;Block size: &quot;</span> &lt;&lt; ekey.size() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 493</span> out_file &lt;&lt; <span class="stringliteral">&quot;Encryption Key:\n&quot;</span> &lt;&lt; ekey;</div>
<div class="line"><span class="lineno"> 494</span> out_file &lt;&lt; <span class="stringliteral">&quot;\nDecryption Key:\n&quot;</span> &lt;&lt; dkey;</div>
<div class="line"><span class="lineno"> 495</span> out_file.close();</div>
<div class="line"><span class="lineno"> 496</span> </div>
<div class="line"><span class="lineno"> 497</span> assert(txt_back == text);</div>
<div class="line"><span class="lineno"> 498</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Passed :)\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 499</span>}</div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a405b0a28d66a61239d3565d5256f9cb5"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">ciphers::HillCipher::generate_keys</a></div><div class="ttdeci">static std::pair&lt; matrix&lt; int &gt;, matrix&lt; int &gt; &gt; generate_keys(size_t size, int limit1=0, int limit2=10)</div><div class="ttdoc">Generate encryption and decryption key pair.</div><div class="ttdef"><b>Definition</b> <a href="../../d7/db9/hill__cipher_8cpp_source.html#l00425">hill_cipher.cpp:425</a></div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a427acfac1dbff3f48a2b071d449d965b"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b">ciphers::HillCipher::decrypt_text</a></div><div class="ttdeci">static const std::string decrypt_text(const std::string &amp;text, const matrix&lt; int &gt; &amp;decrypt_key)</div><div class="ttdoc">Decrypt a given text using a given key.</div><div class="ttdef"><b>Definition</b> <a href="../../d7/db9/hill__cipher_8cpp_source.html#l00458">hill_cipher.cpp:458</a></div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_aa8bbb6e4a5749f6008b06602d5103917"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">ciphers::HillCipher::encrypt_text</a></div><div class="ttdeci">static const std::string encrypt_text(const std::string &amp;text, const matrix&lt; int &gt; &amp;encrypt_key)</div><div class="ttdoc">Encrypt a given text using a given key.</div><div class="ttdef"><b>Definition</b> <a href="../../d7/db9/hill__cipher_8cpp_source.html#l00446">hill_cipher.cpp:446</a></div></div>
<p class="definition">Definition at line <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html#l00470">470</a> of file <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html">hill_cipher.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 470</span> {</div>
<div class="line"><span class="lineno"> 471</span> <span class="comment">// std::string text = &quot;Hello world!&quot;;</span></div>
<div class="line"><span class="lineno"> 472</span> std::cout &lt;&lt; <span class="stringliteral">&quot;======Test 1 (3x3 key) ======\nOriginal text:\n\t&quot;</span> &lt;&lt; text</div>
<div class="line"><span class="lineno"> 473</span> &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 474</span> </div>
<div class="line"><span class="lineno"> 475</span> std::pair&lt;matrix&lt;int&gt;, <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a>&gt; p =</div>
<div class="line"><span class="lineno"> 476</span> <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">ciphers::HillCipher::generate_keys</a>(3, 0, 100);</div>
<div class="line"><span class="lineno"> 477</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> ekey = p.first;</div>
<div class="line"><span class="lineno"> 478</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> dkey = p.second;</div>
<div class="line"><span class="lineno"> 479</span> </div>
<div class="line"><span class="lineno"> 480</span> <span class="comment">// matrix&lt;int&gt; ekey = {{22, 28, 25}, {5, 26, 15}, {14, 18, 9}};</span></div>
<div class="line"><span class="lineno"> 481</span> <span class="comment">// std::cout &lt;&lt; &quot;Encryption key: \n&quot; &lt;&lt; ekey;</span></div>
<div class="line"><span class="lineno"> 482</span> std::string gibberish = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">ciphers::HillCipher::encrypt_text</a>(text, ekey);</div>
<div class="line"><span class="lineno"> 483</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Encrypted text:\n\t&quot;</span> &lt;&lt; gibberish &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 484</span> </div>
<div class="line"><span class="lineno"> 485</span> <span class="comment">// matrix&lt;int&gt; dkey = ciphers::HillCipher::generate_decryption_key(ekey);</span></div>
<div class="line"><span class="lineno"> 486</span> <span class="comment">// std::cout &lt;&lt; &quot;Decryption key: \n&quot; &lt;&lt; dkey;</span></div>
<div class="line"><span class="lineno"> 487</span> std::string txt_back = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b">ciphers::HillCipher::decrypt_text</a>(gibberish, dkey);</div>
<div class="line"><span class="lineno"> 488</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Reconstruct text:\n\t&quot;</span> &lt;&lt; txt_back &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 489</span> </div>
<div class="line"><span class="lineno"> 490</span> std::ofstream out_file(<span class="stringliteral">&quot;hill_cipher_test1.txt&quot;</span>);</div>
<div class="line"><span class="lineno"> 491</span> out_file &lt;&lt; <span class="stringliteral">&quot;Block size: &quot;</span> &lt;&lt; ekey.size() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 492</span> out_file &lt;&lt; <span class="stringliteral">&quot;Encryption Key:\n&quot;</span> &lt;&lt; ekey;</div>
<div class="line"><span class="lineno"> 493</span> out_file &lt;&lt; <span class="stringliteral">&quot;\nDecryption Key:\n&quot;</span> &lt;&lt; dkey;</div>
<div class="line"><span class="lineno"> 494</span> out_file.close();</div>
<div class="line"><span class="lineno"> 495</span> </div>
<div class="line"><span class="lineno"> 496</span> assert(txt_back == text);</div>
<div class="line"><span class="lineno"> 497</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Passed :)\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 498</span>}</div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a405b0a28d66a61239d3565d5256f9cb5"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">ciphers::HillCipher::generate_keys</a></div><div class="ttdeci">static std::pair&lt; matrix&lt; int &gt;, matrix&lt; int &gt; &gt; generate_keys(size_t size, int limit1=0, int limit2=10)</div><div class="ttdoc">Generate encryption and decryption key pair.</div><div class="ttdef"><b>Definition</b> <a href="../../d7/db9/hill__cipher_8cpp_source.html#l00424">hill_cipher.cpp:424</a></div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a427acfac1dbff3f48a2b071d449d965b"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b">ciphers::HillCipher::decrypt_text</a></div><div class="ttdeci">static const std::string decrypt_text(const std::string &amp;text, const matrix&lt; int &gt; &amp;decrypt_key)</div><div class="ttdoc">Decrypt a given text using a given key.</div><div class="ttdef"><b>Definition</b> <a href="../../d7/db9/hill__cipher_8cpp_source.html#l00457">hill_cipher.cpp:457</a></div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_aa8bbb6e4a5749f6008b06602d5103917"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">ciphers::HillCipher::encrypt_text</a></div><div class="ttdeci">static const std::string encrypt_text(const std::string &amp;text, const matrix&lt; int &gt; &amp;encrypt_key)</div><div class="ttdoc">Encrypt a given text using a given key.</div><div class="ttdef"><b>Definition</b> <a href="../../d7/db9/hill__cipher_8cpp_source.html#l00445">hill_cipher.cpp:445</a></div></div>
<div class="ttc" id="alu__decomposition_8h_html_ac029b636b353cefbb18b2fcc71e427e4"><div class="ttname"><a href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix</a></div><div class="ttdeci">std::vector&lt; std::valarray&lt; T &gt; &gt; matrix</div><div class="ttdef"><b>Definition</b> <a href="../../d1/dbe/lu__decomposition_8h_source.html#l00019">lu_decomposition.h:19</a></div></div>
</div><!-- fragment -->
</div>
@@ -341,32 +341,32 @@ template&lt;typename T&gt; </div>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html#l00506">506</a> of file <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html">hill_cipher.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 506</span> {</div>
<div class="line"><span class="lineno"> 507</span> <span class="comment">// std::string text = &quot;Hello world!&quot;;</span></div>
<div class="line"><span class="lineno"> 508</span> std::cout &lt;&lt; <span class="stringliteral">&quot;======Test 2 (8x8 key) ======\nOriginal text:\n\t&quot;</span> &lt;&lt; text</div>
<div class="line"><span class="lineno"> 509</span> &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 510</span> </div>
<div class="line"><span class="lineno"> 511</span> std::pair&lt;matrix&lt;int&gt;, <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a>&gt; p =</div>
<div class="line"><span class="lineno"> 512</span> <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">ciphers::HillCipher::generate_keys</a>(8, 0, 3);</div>
<div class="line"><span class="lineno"> 513</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> ekey = p.first;</div>
<div class="line"><span class="lineno"> 514</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> dkey = p.second;</div>
<div class="line"><span class="lineno"> 515</span> </div>
<div class="line"><span class="lineno"> 516</span> std::string gibberish = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">ciphers::HillCipher::encrypt_text</a>(text, ekey);</div>
<div class="line"><span class="lineno"> 517</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Encrypted text:\n\t&quot;</span> &lt;&lt; gibberish &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 518</span> </div>
<div class="line"><span class="lineno"> 519</span> std::string txt_back = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b">ciphers::HillCipher::decrypt_text</a>(gibberish, dkey);</div>
<div class="line"><span class="lineno"> 520</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Reconstruct text:\n\t&quot;</span> &lt;&lt; txt_back &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 521</span> </div>
<div class="line"><span class="lineno"> 522</span> std::ofstream out_file(<span class="stringliteral">&quot;hill_cipher_test2.txt&quot;</span>);</div>
<div class="line"><span class="lineno"> 523</span> out_file &lt;&lt; <span class="stringliteral">&quot;Block size: &quot;</span> &lt;&lt; ekey.size() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 524</span> out_file &lt;&lt; <span class="stringliteral">&quot;Encryption Key:\n&quot;</span> &lt;&lt; ekey;</div>
<div class="line"><span class="lineno"> 525</span> out_file &lt;&lt; <span class="stringliteral">&quot;\nDecryption Key:\n&quot;</span> &lt;&lt; dkey;</div>
<div class="line"><span class="lineno"> 526</span> out_file.close();</div>
<div class="line"><span class="lineno"> 527</span> </div>
<div class="line"><span class="lineno"> 528</span> assert(txt_back.compare(0, text.size(), text) == 0);</div>
<div class="line"><span class="lineno"> 529</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Passed :)\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 530</span>}</div>
<p class="definition">Definition at line <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html#l00505">505</a> of file <a class="el" href="../../d7/db9/hill__cipher_8cpp_source.html">hill_cipher.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 505</span> {</div>
<div class="line"><span class="lineno"> 506</span> <span class="comment">// std::string text = &quot;Hello world!&quot;;</span></div>
<div class="line"><span class="lineno"> 507</span> std::cout &lt;&lt; <span class="stringliteral">&quot;======Test 2 (8x8 key) ======\nOriginal text:\n\t&quot;</span> &lt;&lt; text</div>
<div class="line"><span class="lineno"> 508</span> &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 509</span> </div>
<div class="line"><span class="lineno"> 510</span> std::pair&lt;matrix&lt;int&gt;, <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a>&gt; p =</div>
<div class="line"><span class="lineno"> 511</span> <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">ciphers::HillCipher::generate_keys</a>(8, 0, 3);</div>
<div class="line"><span class="lineno"> 512</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> ekey = p.first;</div>
<div class="line"><span class="lineno"> 513</span> <a class="code hl_typedef" href="../../d1/dbe/lu__decomposition_8h.html#ac029b636b353cefbb18b2fcc71e427e4">matrix&lt;int&gt;</a> dkey = p.second;</div>
<div class="line"><span class="lineno"> 514</span> </div>
<div class="line"><span class="lineno"> 515</span> std::string gibberish = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">ciphers::HillCipher::encrypt_text</a>(text, ekey);</div>
<div class="line"><span class="lineno"> 516</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Encrypted text:\n\t&quot;</span> &lt;&lt; gibberish &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 517</span> </div>
<div class="line"><span class="lineno"> 518</span> std::string txt_back = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b">ciphers::HillCipher::decrypt_text</a>(gibberish, dkey);</div>
<div class="line"><span class="lineno"> 519</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Reconstruct text:\n\t&quot;</span> &lt;&lt; txt_back &lt;&lt; std::endl;</div>
<div class="line"><span class="lineno"> 520</span> </div>
<div class="line"><span class="lineno"> 521</span> std::ofstream out_file(<span class="stringliteral">&quot;hill_cipher_test2.txt&quot;</span>);</div>
<div class="line"><span class="lineno"> 522</span> out_file &lt;&lt; <span class="stringliteral">&quot;Block size: &quot;</span> &lt;&lt; ekey.size() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 523</span> out_file &lt;&lt; <span class="stringliteral">&quot;Encryption Key:\n&quot;</span> &lt;&lt; ekey;</div>
<div class="line"><span class="lineno"> 524</span> out_file &lt;&lt; <span class="stringliteral">&quot;\nDecryption Key:\n&quot;</span> &lt;&lt; dkey;</div>
<div class="line"><span class="lineno"> 525</span> out_file.close();</div>
<div class="line"><span class="lineno"> 526</span> </div>
<div class="line"><span class="lineno"> 527</span> assert(txt_back.compare(0, text.size(), text) == 0);</div>
<div class="line"><span class="lineno"> 528</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Passed :)\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 529</span>}</div>
</div><!-- fragment -->
</div>
</div>