https://github.com/beached/crypto_helpers
Crypto Helper Library
https://github.com/beached/crypto_helpers
Last synced: 2 months ago
JSON representation
Crypto Helper Library
- Host: GitHub
- URL: https://github.com/beached/crypto_helpers
- Owner: beached
- License: mit
- Created: 2017-09-19T00:16:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-09T01:06:11.000Z (over 5 years ago)
- Last Synced: 2025-01-07T21:12:53.555Z (4 months ago)
- Language: C++
- Size: 60.5 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
### Crypto Helpers
## SHA256 - in constexpr
# literals
""_sha256 Creates a sha256_hash_string(struct that is implicitly convertable to a c_str) at compile time
""_sha256_digest Creates a SHA256 digest at compile time
""_sha256str Creates a std::string of the SHA256 hash# Literal Examples
``` C++
using daw::crypto_literals;
auto hash = "Hello Word"_sha256
std::cout << hash << '\n';
```
Would output
```
a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
```# Function calls
The sha256_bin( some string like thing ) genrate a sha256 digest which contains the binary hash
``` C++
template>
constexpr sha256_digest_t sha256_bin( daw::basic_string_view sv ) noexcept;template>
constexpr sha256_digest_t sha256_bin( CharT const *str, size_t len ) noexcept;template>
constexpr sha256_digest_t sha256_bin( CharT const ( &str )[N] ) noexcept;
```The sha256( some string like thing ) creates a sha256_hash_string which is implicitly converable to a c_str. sha256str will create std::string but lacks constexpr
``` C++
template>
constexpr sha256_hash_string sha256( daw::basic_string_view sv ) noexcept;template>
constexpr sha256_hash_string sha256( CharT const *str, size_t len ) noexcept;template>
constexpr sha256_hash_string sha256( CharT const ( &str )[N] ) noexcept;template
inline std::string sha256str( Args&&... args ) noexcept;
```