From 3b1fcbe825c90dcb5e358ad7632b45d4cd512f54 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 6 Sep 2005 20:08:39 +0000 Subject: New namespace for message digest algorithms. --- src/security/digest/messageDigest.cpp | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/security/digest/messageDigest.cpp (limited to 'src/security/digest/messageDigest.cpp') 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 +// +// 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 + + +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 + -- cgit v1.2.3