mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-23 21:32:09 +08:00
Documentation for f7a5aecce5
This commit is contained in:
@@ -150,7 +150,7 @@ Functions</h2></td></tr>
|
||||
<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>
|
||||
<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_md74"></a>
|
||||
<h3><a class="anchor" id="autotoc_md75"></a>
|
||||
Algorithm</h3>
|
||||
<p >The first step of the algorithm is to pad the message for its length to be a multiple of 64 (bytes). This is done by first adding 0x80 (10000000) and then only zeroes until the last 8 bytes must be filled, where then the 64 bit size of the input will be added</p>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user