added _SLS to MD5 functions, added a separate lib for the md5 C code

This commit is contained in:
Erik Frojdh
2021-09-16 14:10:02 +02:00
parent 2ff50750f5
commit 7fd174c21e
8 changed files with 61 additions and 43 deletions

View File

@ -1,5 +1,7 @@
#include "sls/md5_helper.h"
#include "sls/md5.h"
#include <iomanip>
#include <sstream>
#include <stdexcept>
@ -8,15 +10,15 @@ namespace sls {
std::string md5_calculate_checksum(char *buffer, ssize_t bytes) {
MD5_CTX c;
if (!MD5_Init(&c)) {
if (!MD5_Init_SLS(&c)) {
throw std::runtime_error(
"Could not calculate md5 checksum.[initializing]");
}
if (!MD5_Update(&c, buffer, bytes)) {
if (!MD5_Update_SLS(&c, buffer, bytes)) {
throw std::runtime_error("Could not calculate md5 checksum.[Updating]");
}
unsigned char out[MD5_DIGEST_LENGTH];
if (!MD5_Final(out, &c)) {
if (!MD5_Final_SLS(out, &c)) {
throw std::runtime_error("Could not calculate md5 checksum.[Final]");
}
std::ostringstream oss;