MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / MD5Hash

Function MD5Hash

extensions/standard-processors/processors/HashContent.h:50–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48#define HASH_BUFFER_SIZE 16384
49
50 HashReturnType MD5Hash(const std::shared_ptr<org::apache::nifi::minifi::io::BaseStream>& stream) {
51 HashReturnType ret_val;
52 ret_val.second = 0;
53 uint8_t buffer[HASH_BUFFER_SIZE];
54 MD5_CTX context;
55 MD5_Init(&context);
56
57 size_t ret = 0;
58 do {
59 ret = stream->read(buffer, HASH_BUFFER_SIZE);
60 if (ret > 0) {
61 MD5_Update(&context, buffer, ret);
62 ret_val.second += ret;
63 }
64 } while (ret > 0);
65
66 if (ret_val.second > 0) {
67 unsigned char digest[MD5_DIGEST_LENGTH];
68 MD5_Final(digest, &context);
69 ret_val.first = utils::StringUtils::to_hex(digest, MD5_DIGEST_LENGTH, true /*uppercase*/);
70 }
71 return ret_val;
72 }
73
74 HashReturnType SHA1Hash(const std::shared_ptr<org::apache::nifi::minifi::io::BaseStream>& stream) {
75 HashReturnType ret_val;

Callers

nothing calls this directly

Calls 1

readMethod · 0.45

Tested by

no test coverage detected