<commit_before># PicoSHA2 - a C++ SHA256 hash generator

Copyright &copy; 2014 okdshin

## Introduction

PicoSHA2 is a tiny SHA256 hash generator for C++ with following properties:

- header-file only
- no external dependencies (only uses standard C++ libraries)
- STL-friendly
- licensed under MIT License

## Generating SHA256 hash hex string from byte stream

<pre>
picosha2::hash256_one_by_one hasher;
...
hasher.process(block.begin(), block.end());
...
hasher.finish();
std::string hex_str = picosha2::get_hash_hex_string(hasher);
</pre>

example/interactive_hasher.cpp has more detail information.

## Generating SHA256 hash hex string from std::string

<pre>
std::string src_str = "The quick brown fox jumps over the lazy dog";
std::string hash_hex_str;
picosha2::hash256_hex_string(src_str, hash_hex_str);
std::cout &lt;&lt; hash_hex_str &lt;&lt; std::endl;
//this output is "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"
</pre>
<commit_msg>update document<commit_after># PicoSHA2 - a C++ SHA256 hash generator

Copyright &copy; 2014 okdshin

## Introduction

PicoSHA2 is a tiny SHA256 hash generator for C++ with following properties:

- header-file only
- no external dependencies (only uses standard C++ libraries)
- STL-friendly
- licensed under MIT License

## Generation SHA256 hash

<pre>
// any container (vector, deque, list...)
std::string src_str = "The quick brown fox jumps over the lazy dog";
std::vector&lt;unsigned char&gt; hash(32);
picosha2::hash256(src_str.begin(), src_str.end(), hash.begin(), hash.end());
</pre>

## Generating SHA256 hash hex string from byte stream

<pre>
picosha2::hash256_one_by_one hasher;
...
hasher.process(block.begin(), block.end());
...
hasher.finish();
std::string hex_str = picosha2::get_hash_hex_string(hasher);
</pre>

example/interactive_hasher.cpp has more detail information.

## Generation SHA256 hash from a file

<pre>
std::ifstream ifs("file.txt", std::ios::binary);
std::vector&lt;unsigned char&gt; hash(32);
picosha2::hash256(std::istream_iterator<char>(ifs), std::istream_iterator<char>(), hash.begin(), hash.end());
</pre>

## Generating SHA256 hash hex string from std::string

<pre>
std::string src_str = "The quick brown fox jumps over the lazy dog";
std::string hash_hex_str;
picosha2::hash256_hex_string(src_str, hash_hex_str);
std::cout &lt;&lt; hash_hex_str &lt;&lt; std::endl;
//this output is "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"
</pre>

{'fraction_non_alphanumeric': 0.12971220105391162, 'fraction_numerical': 0.05999189298743413, 'mean_word_length': 6.051428571428572, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1394893', 'n_tokens_mistral': 943, 'n_tokens_neox': 860, 'n_words': 237}