mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-30 16:06:24 +08:00
Documentation for db149bf3b7
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.4"/>
|
||||
<meta name="generator" content="Doxygen 1.9.5"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: hashing/sha1.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -41,10 +41,10 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.4 -->
|
||||
<!-- Generated by Doxygen 1.9.5 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="../../menudata.js"></script>
|
||||
@@ -84,9 +84,16 @@ $(document).ready(function(){initNavTree('d8/d7a/sha1_8cpp.html','../../'); init
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<iframe src="javascript:void(0)" frameborder="0"
|
||||
name="MSearchResults" id="MSearchResults">
|
||||
</iframe>
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
@@ -109,7 +116,7 @@ $(document).ready(function(){initNavTree('d8/d7a/sha1_8cpp.html','../../'); init
|
||||
</div><div class="textblock"><div class="dynheader">
|
||||
Include dependency graph for sha1.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d3/d4c/sha1_8cpp__incl.svg" width="595" height="112"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d3/d4c/sha1_8cpp__incl.svg" width="595" height="110"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div><table class="memberdecls">
|
||||
@@ -148,7 +155,7 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p >Simple C++ implementation of the <a href="https://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1 Hashing Algorithm</a> </p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/tGautot" target="_blank">tGautot</a></dd></dl>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/tGautot" target="_blank">tGautot</a> </dd></dl>
|
||||
<p><a href="https://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1</a> is a cryptographic hash function that was developped by the <a href="https://en.wikipedia.org/wiki/National_Security_Agency" target="_blank">NSA</a> 1995. SHA-1 is not considered secure since around 2010.</p>
|
||||
<h3><a class="anchor" id="autotoc_md81"></a>
|
||||
Algorithm</h3>
|
||||
@@ -156,7 +163,7 @@ Algorithm</h3>
|
||||
<p >Once this is done, the algo breaks down this padded message into 64 bytes chunks. Each chunk is used for one <em>round</em>, a round breaks the chunk into 16 blocks of 4 bytes. These 16 blocks are then extended to 80 blocks using <a class="el" href="../../d7/d47/namespace_x_o_r.html" title="Functions for XOR cipher algorithm.">XOR</a> operations on existing blocks (see code for more details). The algorithm will then update its 160-bit state (here represented used 5 32-bits integer) using partial hashes computed using special functions on the blocks previously built. Please take a look at the <a href="https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode" target="_blank">wikipedia article</a> for more precision on these operations </p><dl class="section note"><dt>Note</dt><dd>This is a simple implementation for a byte string but some implmenetations can work on bytestream, messages of unknown length. </dd></dl>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="a2397f2444a05e4d1487c67e215410d3c" name="a2397f2444a05e4d1487c67e215410d3c"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a2397f2444a05e4d1487c67e215410d3c">◆ </a></span>hash()</h2>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a2397f2444a05e4d1487c67e215410d3c">◆ </a></span>hash()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -187,14 +194,14 @@ Algorithm</h3>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_a2397f2444a05e4d1487c67e215410d3c_cgraph.svg" width="310" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_a2397f2444a05e4d1487c67e215410d3c_cgraph.svg" width="310" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="a7be3471f7e489d7d0df42b97a48bf141" name="a7be3471f7e489d7d0df42b97a48bf141"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a7be3471f7e489d7d0df42b97a48bf141">◆ </a></span>hash_bs()</h2>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a7be3471f7e489d7d0df42b97a48bf141">◆ </a></span>hash_bs()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -357,14 +364,14 @@ Here is the call graph for this function:</div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_a7be3471f7e489d7d0df42b97a48bf141_cgraph.svg" width="342" height="88"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_a7be3471f7e489d7d0df42b97a48bf141_cgraph.svg" width="342" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="ac9e1a11f44135b890dd10a00e73b5661" name="ac9e1a11f44135b890dd10a00e73b5661"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ac9e1a11f44135b890dd10a00e73b5661">◆ </a></span>interactive()</h2>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ac9e1a11f44135b890dd10a00e73b5661">◆ </a></span>interactive()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -419,14 +426,14 @@ Here is the call graph for this function:</div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_ac9e1a11f44135b890dd10a00e73b5661_cgraph.svg" width="280" height="139"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_ac9e1a11f44135b890dd10a00e73b5661_cgraph.svg" width="280" height="135"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="acf6bd970f29a68702bdbdfe8338e45e0" name="acf6bd970f29a68702bdbdfe8338e45e0"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#acf6bd970f29a68702bdbdfe8338e45e0">◆ </a></span>leftRotate32bits()</h2>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#acf6bd970f29a68702bdbdfe8338e45e0">◆ </a></span>leftRotate32bits()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -468,7 +475,7 @@ Here is the call graph for this function:</div>
|
||||
</div>
|
||||
</div>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">◆ </a></span>main()</h2>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">◆ </a></span>main()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -498,14 +505,14 @@ Here is the call graph for this function:</div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="379" height="190"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="379" height="135"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="aada0803ef851d831b7a290a924e3c228" name="aada0803ef851d831b7a290a924e3c228"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#aada0803ef851d831b7a290a924e3c228">◆ </a></span>sig2hex()</h2>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#aada0803ef851d831b7a290a924e3c228">◆ </a></span>sig2hex()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -543,7 +550,7 @@ Here is the call graph for this function:</div>
|
||||
</div>
|
||||
</div>
|
||||
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">◆ </a></span>test()</h2>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">◆ </a></span>test()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -574,7 +581,7 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><span class="lineno"> 224</span> <span class="comment">// Prints signature hex representation</span></div>
|
||||
<div class="line"><span class="lineno"> 225</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <a class="code hl_function" href="../../d8/d7a/sha1_8cpp.html#aada0803ef851d831b7a290a924e3c228">hashing::sha1::sig2hex</a>(sig) << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 226</span> <span class="comment">// Test with cassert wether sig is correct from expected value</span></div>
|
||||
<div class="line"><span class="lineno"> 227</span> assert(hashing::sha1::sig2hex(sig).<a class="code hl_function" href="../../d4/d7a/shell__sort2_8cpp.html#a7eb77daed2cf1513f6d68c47a1c2db1c">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 227</span> assert(hashing::sha1::sig2hex(sig).<a class="code hl_struct" href="../../d1/db3/structcompare.html">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 228</span> <span class="stringliteral">"da39a3ee5e6b4b0d3255bfef95601890afd80709"</span>) == 0);</div>
|
||||
<div class="line"><span class="lineno"> 229</span> </div>
|
||||
<div class="line"><span class="lineno"> 230</span> <span class="comment">// Hashes "The quick brown fox jumps over the lazy dog" and stores signature</span></div>
|
||||
@@ -585,7 +592,7 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><span class="lineno"> 235</span> <span class="comment">// Prints signature hex representation</span></div>
|
||||
<div class="line"><span class="lineno"> 236</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <a class="code hl_function" href="../../d8/d7a/sha1_8cpp.html#aada0803ef851d831b7a290a924e3c228">hashing::sha1::sig2hex</a>(sig2) << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 237</span> <span class="comment">// Test with cassert wether sig is correct from expected value</span></div>
|
||||
<div class="line"><span class="lineno"> 238</span> assert(hashing::sha1::sig2hex(sig2).<a class="code hl_function" href="../../d4/d7a/shell__sort2_8cpp.html#a7eb77daed2cf1513f6d68c47a1c2db1c">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 238</span> assert(hashing::sha1::sig2hex(sig2).<a class="code hl_struct" href="../../d1/db3/structcompare.html">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 239</span> <span class="stringliteral">"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"</span>) == 0);</div>
|
||||
<div class="line"><span class="lineno"> 240</span> </div>
|
||||
<div class="line"><span class="lineno"> 241</span> <span class="comment">// Hashes "The quick brown fox jumps over the lazy dog." (notice the</span></div>
|
||||
@@ -598,7 +605,7 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><span class="lineno"> 248</span> <span class="comment">// Prints signature hex representation</span></div>
|
||||
<div class="line"><span class="lineno"> 249</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <a class="code hl_function" href="../../d8/d7a/sha1_8cpp.html#aada0803ef851d831b7a290a924e3c228">hashing::sha1::sig2hex</a>(sig3) << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 250</span> <span class="comment">// Test with cassert wether sig is correct from expected value</span></div>
|
||||
<div class="line"><span class="lineno"> 251</span> assert(hashing::sha1::sig2hex(sig3).<a class="code hl_function" href="../../d4/d7a/shell__sort2_8cpp.html#a7eb77daed2cf1513f6d68c47a1c2db1c">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 251</span> assert(hashing::sha1::sig2hex(sig3).<a class="code hl_struct" href="../../d1/db3/structcompare.html">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 252</span> <span class="stringliteral">"408d94384216f890ff7a0c3528e8bed1e0b01621"</span>) == 0);</div>
|
||||
<div class="line"><span class="lineno"> 253</span> </div>
|
||||
<div class="line"><span class="lineno"> 254</span> <span class="comment">// Hashes "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"</span></div>
|
||||
@@ -612,14 +619,14 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><span class="lineno"> 262</span> <span class="comment">// Prints signature hex representation</span></div>
|
||||
<div class="line"><span class="lineno"> 263</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <a class="code hl_function" href="../../d8/d7a/sha1_8cpp.html#aada0803ef851d831b7a290a924e3c228">hashing::sha1::sig2hex</a>(sig4) << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 264</span> <span class="comment">// Test with cassert wether sig is correct from expected value</span></div>
|
||||
<div class="line"><span class="lineno"> 265</span> assert(hashing::sha1::sig2hex(sig4).<a class="code hl_function" href="../../d4/d7a/shell__sort2_8cpp.html#a7eb77daed2cf1513f6d68c47a1c2db1c">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 265</span> assert(hashing::sha1::sig2hex(sig4).<a class="code hl_struct" href="../../d1/db3/structcompare.html">compare</a>(</div>
|
||||
<div class="line"><span class="lineno"> 266</span> <span class="stringliteral">"761c457bf73b14d27e9e9265c46f4b4dda11f940"</span>) == 0);</div>
|
||||
<div class="line"><span class="lineno"> 267</span>}</div>
|
||||
<div class="ttc" id="ashell__sort2_8cpp_html_a7eb77daed2cf1513f6d68c47a1c2db1c"><div class="ttname"><a href="../../d4/d7a/shell__sort2_8cpp.html#a7eb77daed2cf1513f6d68c47a1c2db1c">compare</a></div><div class="ttdeci">int compare(const void *a, const void *b)</div><div class="ttdef"><b>Definition:</b> shell_sort2.cpp:87</div></div>
|
||||
<div class="ttc" id="astructcompare_html"><div class="ttname"><a href="../../d1/db3/structcompare.html">compare</a></div><div class="ttdef"><b>Definition:</b> huffman.cpp:28</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="175" height="88"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d7a/sha1_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="175" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -631,7 +638,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_ece9b94c107bbaa1dd68197a8c9983b9.html">hashing</a></li><li class="navelem"><a class="el" href="../../d8/d7a/sha1_8cpp.html">sha1.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user