1
//////////////////////////////////////////////////////////////////////
3
// Purpose: wxMD5 Class
4
// Author: Casey O'Donnell
5
// Creator: See Internet RFC 1321
6
// Copyright (C) 1991 - 1992
7
// RSA Data Security, Inc. Created 1991
9
// Last modified: 07/02/2003
10
// Licence: wxWindows license
11
//////////////////////////////////////////////////////////////////////
13
// wxMD5.cpp: implementation of the wxMD5 class.
15
//////////////////////////////////////////////////////////////////////
18
#pragma implementation "wxMD5.h"
21
// for compilers that support precompilation, includes "wx.h"
22
#include "wx/wxprec.h"
36
//////////////////////////////////////////////////////////////////////
37
// Construction/Destruction
38
//////////////////////////////////////////////////////////////////////
42
m_bCalculatedDigest = false;
43
m_pszDigestString[32] = '\0';
46
wxMD5::wxMD5(const wxString& szText)
48
m_bCalculatedDigest = false;
49
m_pszDigestString[32] = '\0';
57
//////////////////////////////////////////////////////////////////////
59
//////////////////////////////////////////////////////////////////////
61
void wxMD5::SetText(const wxString& szText)
63
m_bCalculatedDigest = false;
67
const wxString wxMD5::GetDigest()
69
if (m_bCalculatedDigest) {
70
const wxString szRetVal(m_pszDigestString, wxConvUTF8);
72
} else if (m_szText.IsEmpty()) {
78
MD5Update(&md5Context, (unsigned char*)(m_szText.c_str()), m_szText.Len());
79
MD5Final(m_arrDigest, &md5Context);
82
for (int i = 0; i < 16; i++) {
83
sprintf(&m_pszDigestString[j], "%02x", m_arrDigest[j]);
87
const wxString szRetVal(m_pszDigestString, wxConvUTF8);
93
//////////////////////////////////////////////////////////////////////
95
//////////////////////////////////////////////////////////////////////
97
const wxString wxMD5::GetDigest(const wxString& szText)
101
return md5.GetDigest();