aboutsummaryrefslogtreecommitdiffstats
path: root/src/security/digest/messageDigest.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-09-06 20:08:39 +0000
committerVincent Richard <[email protected]>2005-09-06 20:08:39 +0000
commit3b1fcbe825c90dcb5e358ad7632b45d4cd512f54 (patch)
tree183d183a49b40058a300a7832cfe02c91ec5cab8 /src/security/digest/messageDigest.cpp
parentAdded progression notifications. (diff)
downloadvmime-3b1fcbe825c90dcb5e358ad7632b45d4cd512f54.tar.gz
vmime-3b1fcbe825c90dcb5e358ad7632b45d4cd512f54.zip
New namespace for message digest algorithms.
Diffstat (limited to 'src/security/digest/messageDigest.cpp')
-rw-r--r--src/security/digest/messageDigest.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/security/digest/messageDigest.cpp b/src/security/digest/messageDigest.cpp
new file mode 100644
index 00000000..8fb56543
--- /dev/null
+++ b/src/security/digest/messageDigest.cpp
@@ -0,0 +1,53 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+
+#include "vmime/security/digest/messageDigest.hpp"
+
+#include <sstream>
+
+
+namespace vmime {
+namespace security {
+namespace digest {
+
+
+const string messageDigest::getHexDigest() const
+{
+ const byte* hash = getDigest();
+ const int len = getDigestLength();
+
+ static const unsigned char hex[] = "0123456789abcdef";
+
+ std::ostringstream oss;
+
+ for (int i = 0 ; i < len ; ++i)
+ {
+ oss << hex[(hash[i] & 0xf0) >> 4];
+ oss << hex[(hash[i] & 0x0f)];
+ }
+
+ return oss.str();
+
+}
+
+
+} // digest
+} // security
+} // vmime
+