~ubuntu-branches/ubuntu/karmic/codelite/karmic

« back to all changes in this revision

Viewing changes to QmakePlugin/wxmd5.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-08-15 17:42:43 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090815174243-nlb9ikgigbiybz12
Tags: 1.0.2893+dfsg-0ubuntu1
* debian/rules:
  + Tidy up get-orig-source rule
* debian/control:
  + Bump Standards-Version
  + Change Maintainer email address to @ubuntu.com
  + Drop cdbs build-dependency
* debian/copyright:
  + Update to DEP-5 format
* debian/patches/00_add-fPIC.patch:
  + Dropped, fix upstream
* Closes LP: #413992

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
}