Browse Source

- extended with sha256

master
Andreas Romeyke 3 years ago
parent
commit
d07966b574
2 changed files with 10 additions and 1 deletions
  1. +1
    -1
      src/include/checksum.hpp
  2. +9
    -0
      src/lib/checksum.cpp

+ 1
- 1
src/include/checksum.hpp View File

@ -6,7 +6,7 @@
#include <openssl/sha.h>
using namespace std;
enum checksum_algorithms {md5=1, sha1};
enum checksum_algorithms {md5=1, sha1, sha256};
typedef struct {
long unsigned int octetcount;
long unsigned int streamcount;


+ 9
- 0
src/lib/checksum.cpp View File

@ -34,6 +34,15 @@ string Checksum::checksum_of_file(string filepath, checksum_algorithms alg) {
}
break;
}
case sha256: {
unsigned char result[SHA_DIGEST_LENGTH];
SHA256((unsigned char*) memBlock, fileSize, result);
for (int i=0; i<SHA_DIGEST_LENGTH; i++) {
hex_result<< hex << setw(2) << setfill('0') << (int) result[i];
}
break;
}
}
delete memBlock;
// cout << "# # CHECKSUM for filepath '" << filepath << "' " << hex_result.str() << endl;


Loading…
Cancel
Save