|
trantor
Non-blocking I/O cross-platform TCP network library, using C++14
|
Trantor helper functions. More...
Classes | |
| struct | Hash128 |
| struct | Hash160 |
| struct | Hash256 |
Functions | |
| TRANTOR_EXPORT std::string | toUtf8 (const std::wstring &wstr) |
| Convert a wide string to a UTF-8. | |
| TRANTOR_EXPORT std::wstring | fromUtf8 (const std::string &str) |
| Convert a UTF-8 string to a wide string. | |
| TRANTOR_EXPORT std::string | fromWidePath (const std::wstring &strPath) |
| TRANTOR_EXPORT std::wstring | toWidePath (const std::string &strUtf8Path) |
| const std::string & | toNativePath (const std::string &strPath) |
| std::string | toNativePath (const std::wstring &strPath) |
| const std::string & | fromNativePath (const std::string &strPath) |
| std::string | fromNativePath (const std::wstring &strPath) |
| TRANTOR_EXPORT std::string | tlsBackend () |
| Returns the TLS backend used by trantor. Could be "None", "OpenSSL" or "Botan". | |
| TRANTOR_EXPORT Hash128 | md5 (const void *data, size_t len) |
| Compute the MD5 hash of the given data. | |
| Hash128 | md5 (const std::string &str) |
| TRANTOR_EXPORT Hash160 | sha1 (const void *data, size_t len) |
| Compute the SHA1 hash of the given data. | |
| Hash160 | sha1 (const std::string &str) |
| TRANTOR_EXPORT Hash256 | sha256 (const void *data, size_t len) |
| Compute the SHA256 hash of the given data. | |
| Hash256 | sha256 (const std::string &str) |
| TRANTOR_EXPORT Hash256 | sha3 (const void *data, size_t len) |
| Compute the SHA3 hash of the given data. | |
| Hash256 | sha3 (const std::string &str) |
| TRANTOR_EXPORT Hash256 | blake2b (const void *data, size_t len) |
| Compute the BLAKE2b hash of the given data. | |
| Hash256 | blake2b (const std::string &str) |
| TRANTOR_EXPORT std::string | toHexString (const void *data, size_t len) |
| hex encode the given data | |
| std::string | toHexString (const Hash128 &hash) |
| std::string | toHexString (const Hash160 &hash) |
| std::string | toHexString (const Hash256 &hash) |
| TRANTOR_EXPORT bool | secureRandomBytes (void *ptr, size_t size) |
| Generates cryptographically secure random bytes. | |
Trantor helper functions.
| TRANTOR_EXPORT Hash256 trantor::utils::blake2b | ( | const void * | data, |
| size_t | len ) |
Compute the BLAKE2b hash of the given data.
|
inline |
|
inline |
| TRANTOR_EXPORT std::wstring trantor::utils::fromUtf8 | ( | const std::string & | str | ) |
Convert a UTF-8 string to a wide string.
UCS2 on Windows, UTF-32 on Linux & Mac
| str | String to convert |
| TRANTOR_EXPORT std::string trantor::utils::fromWidePath | ( | const std::wstring & | strPath | ) |
Convert a wide string path with arbitrary directory separators to a UTF-8 portable path for use with trantor.
This is a helper, mainly for Windows and multi-platform projects.
| strPath | Wide string path. |
| TRANTOR_EXPORT Hash128 trantor::utils::md5 | ( | const void * | data, |
| size_t | len ) |
Compute the MD5 hash of the given data.
| TRANTOR_EXPORT bool trantor::utils::secureRandomBytes | ( | void * | ptr, |
| size_t | size ) |
Generates cryptographically secure random bytes.
| ptr | Pointer to the buffer to fill |
| size | Size of the buffer |
When using Botan or on *BSD/macOS, this function will always succeed.
| TRANTOR_EXPORT std::string trantor::utils::toHexString | ( | const void * | data, |
| size_t | len ) |
hex encode the given data
|
inline |
Convert an UTF-8 path to a native path.
This is a helper for non-Windows OSes for multi-platform projects.
Does nothing.
| strPath | UTF-8 path. |
strPath.
|
inline |
Convert an wide string path to a UTF-8 path.
This is a helper, mainly for Windows and multi-platform projects.
| strPath | wide string path. |
| TRANTOR_EXPORT std::string trantor::utils::toUtf8 | ( | const std::wstring & | wstr | ) |
Convert a wide string to a UTF-8.
UCS2 on Windows, UTF-32 on Linux & Mac
| wstr | String to convert |
| TRANTOR_EXPORT std::wstring trantor::utils::toWidePath | ( | const std::string & | strUtf8Path | ) |
Convert a UTF-8 path with arbitrary directory separator to a wide string path.
This is a helper, mainly for Windows and multi-platform projects.
| strUtf8Path | Ascii path considered as being UTF-8. |