# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kmdcodec.h

    00001 /*
    00002    Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
    00003    Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
    00004
    00005    This program is free software; you can redistribute it and/or modify
    00006    it under the terms of the GNU Lesser General Public License (LGPL)
    00007    version 2 as published by the Free Software Foundation.
    00008
    00009    This program is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012    GNU General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public
    00015    License along with this program; if not, write to the Free Software
    00016    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00017
    00018    RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992.
    00019    RSA Data Security, Inc. Created 1991. All rights reserved.
    00020
    00021    The KMD5 class is based on a C++ implementation of
    00022    "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by
    00023    Mordechai T. Abzug,  Copyright (c) 1995.  This implementation
    00024    passes the test-suite as defined in RFC 1321.
    00025
    00026    The encoding and decoding utilities in KCodecs with the exception of
    00027    quoted-printable are based on the java implementation in HTTPClient
    00028    package by Ronald Tschalär Copyright (C) 1996-1999.
    00029
    00030    The quoted-printable codec as described in RFC 2045, section 6.7. is by
    00031    Rik Hemsley (C) 2001.
    00032 */
    00033
    00034 #ifndef _KMDBASE_H
    00035 #define _KMDBASE_H
    00036
    00037 #define KBase64 KCodecs
    00038
    00039 #include <qglobal.h>
    00040 #include <qstring.h>
    00041 #include <qiodevice.h>
    00042
    00071 class KCodecs
    00072 {
    00073 public:
    00074
    00084   static QCString quotedPrintableEncode(const QByteArray & in,
    00085                                         bool useCRLF = true);
    00086
    00099   static QCString quotedPrintableEncode(const QCString & str,
    00100                                         bool useCRLF = true);
    00101
    00121   static void quotedPrintableEncode(const QByteArray & in, QByteArray& out,
    00122                                     bool useCRLF);
    00123
    00132   static QCString quotedPrintableDecode(const QByteArray & in);
    00133
    00143   static QCString quotedPrintableDecode(const QCString & str);
    00144
    00164   static void quotedPrintableDecode(const QByteArray & in, QByteArray& out);
    00165
    00166
    00178   static QCString uuencode( const QByteArray& in );
    00179
    00189   static QCString uuencode( const QCString& str );
    00190
    00206   static void uuencode( const QByteArray& in, QByteArray& out );
    00207
    00218   static QCString uudecode( const QByteArray& in );
    00219
    00229   static QCString uudecode( const QCString& str );
    00230
    00250   static void uudecode( const QByteArray& in, QByteArray& out );
    00251
    00252
    00266   static QCString base64Encode( const QByteArray& in, bool insertLFs = false);
    00267
    00278   static QCString base64Encode( const QCString& str, bool insertLFs = false );
    00279
    00301   static void base64Encode( const QByteArray& in, QByteArray& out,
    00302                             bool insertLFs = false );
    00303
    00311   static QCString base64Decode( const QByteArray& in );
    00312
    00322   static QCString base64Decode( const QCString& str );
    00323
    00341   static void base64Decode( const QByteArray& in, QByteArray& out );
    00342
    00343
    00344 private:
    00345   KCodecs();
    00346
    00347 private:
    00348   static const char UUEncMap[64];
    00349   static const char UUDecMap[128];
    00350   static const char Base64EncMap[64];
    00351   static const char Base64DecMap[128];
    00352   static const char hexChars[16];
    00353   static const unsigned int maxQPLineLength;
    00354 };
    00355
    00356 class KMD5Private;
    00404 class KMD5
    00405 {
    00406 public:
    00407
    00408   typedef unsigned char Digest[16];
    00409
    00410   KMD5();
    00411
    00420   KMD5(const char* in, int len = -1);
    00421
    00427   KMD5(const QByteArray& a );
    00428
    00434   KMD5(const QCString& a );
    00435
    00444   void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); }
    00445
    00449   void update(const unsigned char* in, int len = -1);
    00450
    00456   void update(const QByteArray& in );
    00457
    00463   void update(const QCString& in );
    00464
    00476   bool update(QIODevice& file);
    00477
    00483   void reset();
    00484
    00488   const Digest& rawDigest ();
    00489
    00499   void rawDigest( KMD5::Digest& bin );
    00500
    00505   QCString hexDigest ();
    00506
    00510   void hexDigest(QCString&);
    00511
    00516   QCString base64Digest ();
    00517
    00522   bool verify( const KMD5::Digest& digest);
    00523
    00527   bool verify(const QCString&);
    00528
    00529 protected:
    00534   void transform( const unsigned char buffer[64] );
    00535
    00539   void finalize();
    00540
    00541 private:
    00542   KMD5(const KMD5& u);
    00543   KMD5& operator=(const KMD5& md);
    00544
    00545   void init();
    00546   void encode( unsigned char* output, Q_UINT32 *in, Q_UINT32 len );
    00547   void decode( Q_UINT32 *output, const unsigned char* in, Q_UINT32 len );
    00548
    00549   Q_UINT32 rotate_left( Q_UINT32 x, Q_UINT32 n );
    00550   Q_UINT32 F( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
    00551   Q_UINT32 G( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
    00552   Q_UINT32 H( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
    00553   Q_UINT32 I( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
    00554   void FF( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
    00555                Q_UINT32  s, Q_UINT32 ac );
    00556   void GG( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
    00557                 Q_UINT32 s, Q_UINT32 ac );
    00558   void HH( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
    00559                 Q_UINT32 s, Q_UINT32 ac );
    00560   void II( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
    00561              Q_UINT32 s, Q_UINT32 ac );
    00562
    00563 private:
    00564   Q_UINT32 m_state[4];
    00565   Q_UINT32 m_count[2];
    00566   Q_UINT8 m_buffer[64];
    00567   Digest m_digest;
    00568   bool m_finalized;
    00569
    00570   KMD5Private* d;
    00571 };
    00572 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:46:41 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001