DSL
Classes | Functions
Hash Functions

Classes

struct  HASH_CTX
 

Functions

DSL_API HASH_CTX *DSL_CC hash_init (const char *name)
 
DSL_API void DSL_CC hash_update (HASH_CTX *ctx, const uint8 *input, size_t length)
 Call with the data you want to hash, can be called multiple times to hash a large file in chunks for example.
 
DSL_API bool DSL_CC hash_finish (HASH_CTX *ctx, uint8 *out, size_t outlen)
 Finalize hash and store in out. outlen should be >= hashSize in the HASH_CTX struct. After this no further calls to hash_update() can be made and ctx is destroyed.
 
DSL_API bool DSL_CC hashdata (const char *name, const uint8 *data, size_t datalen, char *out, size_t outlen, bool raw_output=false)
 Wrapper around hash_init()/hash_update()/hash_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 
DSL_API bool DSL_CC hashfile (const char *name, const char *fn, char *out, size_t outlen, bool raw_output=false)
 Wrapper around hash_init()/hash_update()/hash_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 
DSL_API bool DSL_CC hashfile_fp (const char *name, FILE *fp, char *out, size_t outlen, bool raw_output=false)
 Wrapper around hash_init()/hash_update()/hash_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 
DSL_API bool DSL_CC hashfile_rw (const char *name, DSL_FILE *fp, char *out, size_t outlen, bool raw_output=false)
 Wrapper around hash_init()/hash_update()/hash_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 

Detailed Description

Function Documentation

◆ hash_init()

DSL_API HASH_CTX* DSL_CC hash_init ( const char *  name)

Initialize a hashing CTX with hashing algorithm 'name'
Without optional modules we support: sha3-256, sha3-512, sha256, sha512, sha1, md5, keccak256 (the pre-SHA3 version as used by Ethereum), keccak512
With ENABLE_OPENSSL: Adds the full range of OpenSSL supported hash algorithms
With ENABLE_GNUTLS: Adds RIPEMD-160, MD2, SHA224, SHA384
With ENABLE_SODIUM: Adds blake2b
See hashdata(), hashfile(), hashfile_fp(), and hashfile_rw() for one-shot convenience functions. The hashfile* ones automatically hash the file in 32K chunks so it won't try to load the entire file into memory or anything.

Parameters
nameThe name of the hashing algorithm.

Definition at line 49 of file hash.cpp.

Referenced by hashdata(), and hashfile_rw().