19 #include "md5wrapper.h"
28 QString md5wrapper::hashit(QString text) {
35 (
unsigned char *)text.toLatin1().data(),
39 unsigned char buff[16] =
"";
40 md5->MD5Final((
unsigned char *)buff, &ctx);
43 return convToString(buff);
52 QString md5wrapper::convToString(
unsigned char *bytes) {
56 for(
int i = 0; i < 16; i++) {
57 ::sprintf(&asciihash[p],
"%02x", bytes[i]);
61 return QString(asciihash);
67 md5wrapper::md5wrapper() {
73 md5wrapper::~md5wrapper() {
82 QString md5wrapper::getHashFromString(QString text) {
83 return this->hashit(text);
94 QString md5wrapper::getHashFromFile(QString filename) {
99 unsigned char buffer[1024], digest[16];
102 if((file = fopen(filename.toLatin1().data(),
"rb")) == NULL) {
107 md5->MD5Init(&context);
110 while((len = fread(buffer, 1, 1024, file))) {
111 md5->MD5Update(&context, buffer, len);
118 md5->MD5Final(digest, &context);
120 return convToString(digest);