-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmd5.cpp
36 lines (35 loc) · 2.24 KB
/
md5.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// http://ru.wikipedia.org/wiki/MD5
// wrapper for MD5 from http://ftp.gnu.org/gnu/coreutils/coreutils-8.21.tar.xz
// Alexey Potehin <[email protected]>, http://www.gnuplanet.ru/doc/cv
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include "md5.hpp"
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// constructor
md5_t::md5_t()
{
this->pmd5_item = NULL;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// open operation
void md5_t::open(md5_item_t *pmd5_item)
{
md5_init_ctx(&this->ctx);
this->pmd5_item = pmd5_item;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// update hash
void md5_t::update(const void * const p, uint64_t size)
{
if (this->pmd5_item == NULL) return;
md5_process_bytes(p, size, &this->ctx);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// close operation
void md5_t::close()
{
md5_finish_ctx(&this->ctx, this->pmd5_item);
this->pmd5_item = NULL;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//