source: git/ppcc/adlib/md5.h @ aa4d31

spielwiese
Last change on this file since aa4d31 was aa4d31, checked in by Reimer Behrends <behrends@…>, 5 years ago
parallel preprocessor-related fixes.
  • Property mode set to 100644
File size: 788 bytes
Line 
1#pragma once
2
3struct MD5Digest {
4  Word32 a, b, c, d;
5};
6
7class MD5 : public PtrFreeGC {
8private:
9  MD5Digest state;
10  unsigned char fragment[64];
11  Word fragment_length;
12  Word total_length;
13  bool finished;
14public:
15  MD5Digest digest();
16  Str *bytedigest();
17  Str *hexdigest();
18  static MD5Digest digest(Str *str);
19  static Str *bytedigest(Str *str);
20  static Str *hexdigest(Str *str);
21  void reset() {
22    state.a = 0x67452301;
23    state.b = 0xefcdab89;
24    state.c = 0x98badcfe;
25    state.d = 0x10325476;
26    fragment_length = 0;
27    total_length = 0;
28    finished = false;
29  }
30  void update(const void *data, Int len);
31  void update(Str *str) {
32    update(str->c_str(), str->len());
33  }
34  void update_block(const unsigned char *data);
35  void finish();
36  MD5() {
37    reset();
38  }
39};
40
Note: See TracBrowser for help on using the repository browser.