~ubuntu-branches/ubuntu/maverick/codelite/maverick

« back to all changes in this revision

Viewing changes to QmakePlugin/wxmd5.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-02-10 10:13:06 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100210101306-nzt1b7es8mby1eyi
Tags: 2.2.0.3681+dfsg-0ubuntu1
* New upstream release.
* Refresh patches.
* Adjust Makefile to avoid the execution of uninstall target. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//////////////////////////////////////////////////////////////////////
2
 
//      Name:          wxMD5.cpp
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
8
 
//      Created:       07/02/2003
9
 
//      Last modified: 07/02/2003
10
 
//      Licence:       wxWindows license
11
 
//////////////////////////////////////////////////////////////////////
12
 
 
13
 
// wxMD5.cpp: implementation of the wxMD5 class.
14
 
//
15
 
//////////////////////////////////////////////////////////////////////
16
 
 
17
 
#ifdef __GNUG__
18
 
#pragma implementation "wxMD5.h"
19
 
#endif
20
 
 
21
 
// for compilers that support precompilation, includes "wx.h"
22
 
#include "wx/wxprec.h"
23
 
 
24
 
#ifdef __BORLANDC__
25
 
#pragma hdrstop
26
 
#endif
27
 
 
28
 
// for all others
29
 
#ifndef WX_PRECOMP
30
 
#include "wx/wx.h"
31
 
#endif
32
 
 
33
 
#include "wxmd5.h"
34
 
#include "md5.h"
35
 
 
36
 
//////////////////////////////////////////////////////////////////////
37
 
// Construction/Destruction
38
 
//////////////////////////////////////////////////////////////////////
39
 
 
40
 
wxMD5::wxMD5()
41
 
{
42
 
        m_bCalculatedDigest = false;
43
 
        m_pszDigestString[32] = '\0';
44
 
}
45
 
 
46
 
wxMD5::wxMD5(const wxString& szText)
47
 
{
48
 
        m_bCalculatedDigest = false;
49
 
        m_pszDigestString[32] = '\0';
50
 
        m_szText = szText;
51
 
}
52
 
 
53
 
wxMD5::~wxMD5()
54
 
{
55
 
}
56
 
 
57
 
//////////////////////////////////////////////////////////////////////
58
 
// Other Methods
59
 
//////////////////////////////////////////////////////////////////////
60
 
 
61
 
void wxMD5::SetText(const wxString& szText)
62
 
{
63
 
        m_bCalculatedDigest = false;
64
 
        m_szText = szText;
65
 
}
66
 
 
67
 
const wxString wxMD5::GetDigest()
68
 
{
69
 
        if (m_bCalculatedDigest) {
70
 
                const wxString szRetVal(m_pszDigestString, wxConvUTF8);
71
 
                return szRetVal;
72
 
        } else if (m_szText.IsEmpty()) {
73
 
                return wxT("");
74
 
        } else {
75
 
                MD5_CTX md5Context;
76
 
                MD5Init(&md5Context);
77
 
 
78
 
                MD5Update(&md5Context, (unsigned char*)(m_szText.c_str()), m_szText.Len());
79
 
                MD5Final(m_arrDigest, &md5Context);
80
 
 
81
 
                int j = 0;
82
 
                for (int i = 0; i < 16; i++) {
83
 
                        sprintf(&m_pszDigestString[j], "%02x", m_arrDigest[j]);
84
 
                        j += 2;
85
 
                }
86
 
 
87
 
                const wxString szRetVal(m_pszDigestString, wxConvUTF8);
88
 
 
89
 
                return szRetVal;
90
 
        }
91
 
}
92
 
 
93
 
//////////////////////////////////////////////////////////////////////
94
 
// Static Methods
95
 
//////////////////////////////////////////////////////////////////////
96
 
 
97
 
const wxString wxMD5::GetDigest(const wxString& szText)
98
 
{
99
 
        wxMD5 md5(szText);
100
 
 
101
 
        return md5.GetDigest();
102
 
}