All Projects → okdshin → Picosha2

okdshin / Picosha2

Licence: mit
a header-file-only, SHA256 hash generator in C++

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Picosha2

pysha2
Pure Python implementation of SHA2 (i.e., SHA224, SHA256, SHA384, and SHA512).
Stars: ✭ 52 (-87.25%)
Mutual labels:  sha256, mit-license
Structopt
Parse command line arguments by defining a struct
Stars: ✭ 323 (-20.83%)
Mutual labels:  mit-license
dtls
Datagram Transport Layer Security (DTLS) client.
Stars: ✭ 72 (-82.35%)
Mutual labels:  sha256
Awesome Blockchains
A collection about awesome blockchains - open distributed public databases w/ crypto hashes incl. git ;-). Blockchains are the new tulips 🌷🌷🌷. Distributed is the new centralized.
Stars: ✭ 3,243 (+694.85%)
Mutual labels:  sha256
dups
A CLI tool to find/remove duplicate files supporting multi-core and different algorithms (MD5, SHA256, and XXHash).
Stars: ✭ 21 (-94.85%)
Mutual labels:  sha256
Unity Destruction
💥 An open-source script to destroy objects realistically in Unity3D.
Stars: ✭ 291 (-28.68%)
Mutual labels:  mit-license
Checksum
Checksum calculation extensions for Swift
Stars: ✭ 28 (-93.14%)
Mutual labels:  sha256
Amplitudejs
AmplitudeJS: Open Source HTML5 Web Audio Library. Design your web audio player, the way you want. No dependencies required.
Stars: ✭ 3,781 (+826.72%)
Mutual labels:  mit-license
Md4c
C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
Stars: ✭ 322 (-21.08%)
Mutual labels:  mit-license
Doracms
DoraCMS是基于Nodejs+eggjs+mongodb编写的一套内容管理系统,结构简单,较目前一些开源的cms,doracms易于拓展,特别适合前端开发工程师做二次开发。
Stars: ✭ 3,180 (+679.41%)
Mutual labels:  mit-license
Unrealeditorpythonscripts
Some of my personal scripts i made to use for my own projects, but free of charge to be used for any project and any purpose as long as it is not violating the Unreal Engine EULA.
Stars: ✭ 282 (-30.88%)
Mutual labels:  mit-license
jsonlint
Lightweight command-line tool for validating JSON
Stars: ✭ 27 (-93.38%)
Mutual labels:  mit-license
Exprtk
C++ Mathematical Expression Parsing And Evaluation Library
Stars: ✭ 301 (-26.23%)
Mutual labels:  mit-license
swwmgz m
Codename: Demolitionist. An ambitious GZDoom gameplay mod featuring non-stop over-the-top action, crazy guns, and a cute, sassy robot protagonist, as well as lots of LORE. (Formerly known as SWWM GZ)
Stars: ✭ 23 (-94.36%)
Mutual labels:  mit-license
Bitcoinlib
Bitcoin Core RPC compatible, battle-tested .NET library and RPC wrapper for Bitcoin and Altcoins
Stars: ✭ 350 (-14.22%)
Mutual labels:  mit-license
sintelgame
An open source adventure game created with Blender
Stars: ✭ 81 (-80.15%)
Mutual labels:  mit-license
Covid 19 Statistics Dashboard Angular 9
🦠Corona Virus / Covid 19 Tracker Dashboard With Awesome UI + PWA + NodeJS Scraper
Stars: ✭ 282 (-30.88%)
Mutual labels:  mit-license
Little Cms
A free, open source, CMM engine. It provides fast transforms between ICC profiles.
Stars: ✭ 291 (-28.68%)
Mutual labels:  mit-license
Forge
A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
Stars: ✭ 4,204 (+930.39%)
Mutual labels:  sha256
Magicavoxel Shaders
Shaders for MagicaVoxel to simplify common and repetitive tasks.
Stars: ✭ 370 (-9.31%)
Mutual labels:  mit-license

PicoSHA2 - a C++ SHA256 hash generator

Copyright © 2017 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 and hash hex string

// any STL sequantial container (vector, list, dequeue...)
std::string src_str = "The quick brown fox jumps over the lazy dog";

std::vector<unsigned char> hash(picosha2::k_digest_size);
picosha2::hash256(src_str.begin(), src_str.end(), hash.begin(), hash.end());

std::string hex_str = picosha2::bytes_to_hex_string(hash.begin(), hash.end());

Generating SHA256 hash and hash hex string from byte stream

picosha2::hash256_one_by_one hasher;
...
hasher.process(block.begin(), block.end());
...
hasher.finish();

std::vector<unsigned char> hash(picosha2::k_digest_size);
hasher.get_hash_bytes(hash.begin(), hash.end());

std::string hex_str = picosha2::get_hash_hex_string(hasher);

The file example/interactive_hasher.cpp has more detailed information.

Generating SHA256 hash from a binary file

std::ifstream f("file.txt", std::ios::binary);
std::vector<unsigned char> s(picosha2::k_digest_size);
picosha2::hash256(f, s.begin(), s.end());

This hash256 may use less memory than reading whole of the file.

Generating SHA256 hash hex string from std::string

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 << hash_hex_str << std::endl;
//this output is "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"
std::string src_str = "The quick brown fox jumps over the lazy dog";
std::string hash_hex_str = picosha2::hash256_hex_string(src_str);
std::cout << hash_hex_str << std::endl;
//this output is "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"
std::string src_str = "The quick brown fox jumps over the lazy dog.";//add '.'
std::string hash_hex_str = picosha2::hash256_hex_string(src_str.begin(), src_str.end());
std::cout << hash_hex_str << std::endl;
//this output is "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c"

Generating SHA256 hash hex string from byte sequence

std::vector<unsigned char> src_vect(...);
std::string hash_hex_str;
picosha2::hash256_hex_string(src_vect, hash_hex_str);
std::vector<unsigned char> src_vect(...);
std::string hash_hex_str = picosha2::hash256_hex_string(src_vect);
unsigned char src_c_array[picosha2::k_digest_size] = {...};
std::string hash_hex_str;
picosha2::hash256_hex_string(src_c_array, src_c_array+picosha2::k_digest_size, hash_hex_str);
unsigned char src_c_array[picosha2::k_digest_size] = {...};
std::string hash_hex_str = picosha2::hash256_hex_string(src_c_array, src_c_array+picosha2::k_digest_size);

Generating SHA256 hash byte sequence from STL sequential container

//any STL sequantial container (vector, list, dequeue...)
std::string src_str = "The quick brown fox jumps over the lazy dog";

//any STL sequantial containers (vector, list, dequeue...)
std::vector<unsigned char> hash(picosha2::k_digest_size);

// in: container, out: container
picosha2::hash256(src_str, hash);
//any STL sequantial container (vector, list, dequeue...)
std::string src_str = "The quick brown fox jumps over the lazy dog";

//any STL sequantial containers (vector, list, dequeue...)
std::vector<unsigned char> hash(picosha2::k_digest_size);

// in: iterator pair, out: contaner
picosha2::hash256(src_str.begin(), src_str.end(), hash);
std::string src_str = "The quick brown fox jumps over the lazy dog";
unsigned char hash_byte_c_array[picosha2::k_digest_size];
// in: container, out: iterator(pointer) pair
picosha2::hash256(src_str, hash_byte_c_array, hash_byte_c_array+picosha2::k_digest_size);
std::string src_str = "The quick brown fox jumps over the lazy dog";
std::vector<unsigned char> hash(picosha2::k_digest_size);
// in: iterator pair, out: iterator pair
picosha2::hash256(src_str.begin(), src_str.end(), hash.begin(), hash.end());
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].