Fixed digest
This commit is contained in:
parent
107d752cb8
commit
8882410f35
|
@ -32,20 +32,20 @@
|
||||||
#else
|
#else
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
|
|
||||||
#define DECLARE_DIGEST(name, method, digestLength) \
|
#define DECLARE_DIGEST(name, method, digestLength) \
|
||||||
inline std::string name(const std::string& input) { \
|
inline std::string name(const std::string& input) { \
|
||||||
u_char buffer[digestLength]; \
|
u_char buffer[digestLength]; \
|
||||||
method((u_char*) input.data(), input.length(), buffer); \
|
method((u_char*) input.data(), input.length(), buffer); \
|
||||||
return std::string((const char*) buffer, digestLength); \
|
return std::string((const char*) buffer, digestLength); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
inline std::string name(const char* input, ssize_t length = -1) { \
|
inline std::string name(const char* input, ssize_t length = -1) { \
|
||||||
if(length == -1) length = strlen(input); \
|
if(length == -1) length = strlen(input); \
|
||||||
return name(std::string(input, length)); \
|
return name(std::string(input, digestLength)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
inline void name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
inline void name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
||||||
method((u_char*) input, length, result); \
|
method((u_char*) input, length, digestLength); \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue