]>
Commit | Line | Data |
---|---|---|
58ee6135 RC |
1 | /* |
2 | * Copyright (c) 2000, Red Hat, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by DJ Delorie <dj@cygnus.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | #include "MD5++.h" | |
17 | ||
18 | String | |
19 | md5::print() const | |
20 | { | |
21 | char d1[33]; | |
22 | d1[32] = '\0'; | |
23 | for (int i=0; i < 16; ++i) | |
24 | { | |
25 | char tc = (digest[i] & 0xf0) >> 4; | |
26 | d1[i * 2] = tc < 10 ? tc + '0' : tc + 'a' - 10; | |
27 | tc = digest[i] & 0x0f; | |
28 | d1[i * 2 + 1] = tc < 10 ? tc + '0' : tc + 'a' - 10; | |
29 | } | |
30 | return String(d1); | |
31 | } | |
32 | ||
33 | bool | |
34 | md5::operator == (md5 const &rhs) const | |
35 | { | |
36 | for (int i=0; i < 16; ++i) | |
37 | if (digest[i] != rhs.digest[i]) | |
38 | return false; | |
39 | return true; | |
40 | } | |
41 | ||
42 | bool | |
43 | md5::operator != (md5 const &rhs) const | |
44 | { | |
45 | return !(*this == rhs); | |
46 | } |