![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Simple C++ implementation of the [SHA-256 Hashing Algorithm] (https://en.wikipedia.org/wiki/SHA-2) More...
#include <array>#include <cassert>#include <cstdint>#include <iomanip>#include <iostream>#include <sstream>#include <utility>#include <vector>Go to the source code of this file.
Classes | |
| class | hashing::sha256::Hash |
| Contains hash array and functions to update it and convert it to a hexadecimal string. More... | |
Namespaces | |
| namespace | hashing |
| Used for assert. | |
| namespace | SHA |
| Functions for the SHA-1 algorithm implementation. | |
Functions | |
| uint32_t | hashing::sha256::right_rotate (uint32_t n, size_t rotate) |
| Rotates the bits of a 32-bit unsigned integer. | |
| std::size_t | hashing::sha256::compute_padded_size (const std::size_t input_size) |
| Computes size of the padded input. | |
| template<typename T> | |
| uint8_t | hashing::sha256::extract_byte (const T in_value, const std::size_t byte_num) |
| Returns the byte at position byte_num in in_value. | |
| char | hashing::sha256::get_char (const std::string &input, std::size_t pos) |
| Returns the character at pos after the input is padded. | |
| std::array< uint32_t, 64 > | hashing::sha256::create_message_schedule_array (const std::string &input, const size_t byte_num) |
| Creates the message schedule array. | |
| std::string | hashing::sha256::sha256 (const std::string &input) |
| Computes the final hash value. | |
| static void | test_compute_padded_size () |
| Self-test implementations. | |
| static void | test_extract_byte () |
| static void | test_get_char () |
| static void | test_right_rotate () |
| static void | test_sha256 () |
| static void | test () |
| int | main () |
| Main function. | |
Simple C++ implementation of the [SHA-256 Hashing Algorithm] (https://en.wikipedia.org/wiki/SHA-2)
SHA-2 is a set of cryptographic hash functions that was designed by the NSA and first published in 2001. SHA-256 is a part of the SHA-2 family. SHA-256 is widely used for authenticating software packages and secure password hashing.
Definition in file sha256.cpp.
| std::size_t hashing::sha256::compute_padded_size | ( | const std::size_t | input_size | ) |
Computes size of the padded input.
| input | Input string |
Definition at line 143 of file sha256.cpp.
| std::array< uint32_t, 64 > hashing::sha256::create_message_schedule_array | ( | const std::string & | input, |
| const size_t | byte_num ) |
Creates the message schedule array.
| input | Input string |
| byte_num | Position of the first byte of the chunk |
Definition at line 195 of file sha256.cpp.
| uint8_t hashing::sha256::extract_byte | ( | const T | in_value, |
| const std::size_t | byte_num ) |
Returns the byte at position byte_num in in_value.
| in_value | Input value |
| byte_num | Position of byte to be returned |
Definition at line 157 of file sha256.cpp.
| char hashing::sha256::get_char | ( | const std::string & | input, |
| std::size_t | pos ) |
Returns the character at pos after the input is padded.
| input | Input string |
| pos | Position of character to be returned |
Definition at line 170 of file sha256.cpp.
| int main | ( | void | ) |
| uint32_t hashing::sha256::right_rotate | ( | uint32_t | n, |
| size_t | rotate ) |
Rotates the bits of a 32-bit unsigned integer.
| n | Integer to rotate |
| rotate | Number of bits to rotate |
Definition at line 58 of file sha256.cpp.
| std::string hashing::sha256::sha256 | ( | const std::string & | input | ) |
Computes the final hash value.
| input | Input string |
Definition at line 232 of file sha256.cpp.
|
static |
Definition at line 312 of file sha256.cpp.
|
static |
Self-test implementations.
Definition at line 248 of file sha256.cpp.
|
static |
Definition at line 254 of file sha256.cpp.
|
static |
Definition at line 266 of file sha256.cpp.
|
static |
Definition at line 280 of file sha256.cpp.
|
static |
Definition at line 286 of file sha256.cpp.