Changeset 71


Ignore:
Timestamp:
Sep 23, 2006, 10:37:59 PM (19 years ago)
Author:
dmik
Message:

QCA: Applied somebody's patch (from psi-im.org's Wiki) to fix MSVC 7 build.

Location:
qca/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • qca/trunk/src/qca.cpp

    r27 r71  
    456456// SHA256
    457457//----------------------------------------------------------------------------
     458#if !defined(MSC_NET_HOTFIX)
    458459SHA256::SHA256()
    459460:Hash((QCA_HashContext *)getContext(CAP_SHA256))
    460461{
    461462}
     463#endif
    462464
    463465
  • qca/trunk/src/qca.h

    r27 r71  
    5555#endif
    5656
     57#if defined(_MSC_VER) && _MSC_VER >= 1300
     58#define MSC_NET_HOTFIX
     59#endif
     60
    5761class QHostAddress;
    5862class QStringList;
     
    116120        };
    117121
     122#if !defined(MSC_NET_HOTFIX)
    118123        template <class T>
    119124        class QCA_EXPORT HashStatic
     
    146151                }
    147152        };
     153#endif
    148154
    149155        class QCA_EXPORT Cipher
     
    187193        };
    188194
    189         class QCA_EXPORT SHA1 : public Hash, public HashStatic<SHA1>
     195        class QCA_EXPORT SHA1 : public Hash
     196#if !defined(MSC_NET_HOTFIX)
     197                , public HashStatic<SHA1>
     198#endif
    190199        {
    191200        public:
    192201                SHA1();
    193         };
    194 
     202
     203#if defined(MSC_NET_HOTFIX)
     204                static QByteArray hash(const QByteArray &a)
     205                {
     206                        SHA1 obj;
     207                        obj.update(a);
     208                        return obj.final();
     209                }
     210
     211                static QByteArray hash(const QCString &cs)
     212                {
     213                        QByteArray a(cs.length());
     214                        memcpy(a.data(), cs.data(), a.size());
     215                        return hash(a);
     216                }
     217
     218                static QString hashToString(const QByteArray &a)
     219                {
     220                        return arrayToHex(hash(a));
     221                }
     222
     223                static QString hashToString(const QCString &cs)
     224                {
     225                        return arrayToHex(hash(cs));
     226                }
     227#endif
     228        };
     229
     230#if !defined(MSC_NET_HOTFIX)
    195231        class QCA_EXPORT SHA256 : public Hash, public HashStatic<SHA256>
    196232        {
     
    198234                SHA256();
    199235        };
    200 
    201         class QCA_EXPORT MD5 : public Hash, public HashStatic<MD5>
     236#endif
     237
     238        class QCA_EXPORT MD5 : public Hash
     239#if !defined(MSC_NET_HOTFIX)
     240                , public HashStatic<MD5>
     241#endif
    202242        {
    203243        public:
    204244                MD5();
     245
     246#if defined(MSC_NET_HOTFIX)
     247                static QByteArray hash(const QByteArray &a)
     248                {
     249                        MD5 obj;
     250                        obj.update(a);
     251                        return obj.final();
     252                }
     253
     254                static QByteArray hash(const QCString &cs)
     255                {
     256                        QByteArray a(cs.length());
     257                        memcpy(a.data(), cs.data(), a.size());
     258                        return hash(a);
     259                }
     260
     261                static QString hashToString(const QByteArray &a)
     262                {
     263                        return arrayToHex(hash(a));
     264                }
     265
     266                static QString hashToString(const QCString &cs)
     267                {
     268                        return arrayToHex(hash(cs));
     269                }
     270#endif
    205271        };
    206272
Note: See TracChangeset for help on using the changeset viewer.