⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmdcodec.h

📁 linux下的eva源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
   * The boolean argument determines if the encoded data is going   * to be restricted to 76 characters or less per line as specified   * by RFC 2045.  If @p insertLFs is true, then there will be 76   * characters or less per line.   *   * NOTE: the output array is first reset and then resized   * appropriately before use, hence, all data stored in the   * output array will be lost.   *   * @param in        the data to be encoded using base64.   * @param out       the container for the encoded data.   * @param insertLFs limit the number of characters per line.   */  static void base64Encode( const QByteArray& in, QByteArray& out,                            bool insertLFs = false );  /**   * Decodes the given data that was encoded using the   * base64 algorithm.   *   * @param in   the base64-encoded data to be decoded.   * @return     the decoded data.   */  static QCString base64Decode( const QByteArray& in );  /**   * @overload   *   * Same as the above functions except it accepts   * a null terminated string instead an array.   *   * @param str  the base64-encoded string.   * @return     the decoded string.   */  static QCString base64Decode( const QCString& str );  /**   * Decodes the given data that was encoded with the base64   * algorithm.   *   * Use this function if you want the result of the decoding   * to be placed in another array which cuts down the number   * of copy operation that have to be performed in the process.   * This is also the preferred method for decoding an encoded   * binary data.   *   * NOTE: the output array is first reset and then resized   * appropriately before use, hence, all data stored in the   * output array will be lost.   *   * @param in   the encoded data to be decoded.   * @param out  the container for the decoded data.   */  static void base64Decode( const QByteArray& in, QByteArray& out );private:  QCodecs();private:  static const char UUEncMap[64];  static const char UUDecMap[128];  static const char Base64EncMap[64];  static const char Base64DecMap[128];  static const char hexChars[16];  static const unsigned int maxQPLineLength;};class QMD5Private;/** * Provides an easy to use C++ implementation of RSA's * MD5 algorithm. * * The default constructor is designed to provide much the same * functionality as the most commonly used C-implementation, while * the other three constructors are meant to further simplify the * process of obtaining a digest by calculating the result in a * single step. * * QMD5 is state-based, that means you can add new contents with * update() as long as you didn't request the digest value yet. * After the digest value was requested, the object is "finalized" * and you have to call reset() to be able to do another calculation * with it.  The reason for this behaviour is that upon requesting * the message digest QMD5 has to pad the received contents up to a * 64 byte boundary to calculate its value. After this operation it * is not possible to resume consuming data. * * @sect Usage: * * A common usage of this class: * * <PRE> *  const char* test1; *  QMD5::Digest rawResult; * *  test1 = "This is a simple test."; *  QMD5 context (test1); *  cout << "Hex Digest output: " << context.hexDigest().data() << endl; * </PRE> * * To cut down on the unnecessary overhead of creating multiple QMD5 * objects, you can simply invoke @ref reset() to reuse the same object * in making another calculation: * * <PRE> *  context.reset (); *  context.update ("TWO"); *  context.update ("THREE"); *  cout << "Hex Digest output: " << context.hexDigest().data() << endl; * </PRE> * * @short An adapted C++ implementation of RSA Data Securities MD5 algorithm. * @author Dirk Mueller <mueller@kde.org>, Dawit Alemayehu <adawit@kde.org> */class QMD5{public:  typedef unsigned char Digest[16];  QMD5();  /**   * Constructor that updates the digest for the given string.   *   * @param in   C string or binary data   * @param len  if negative, calculates the length by using   *             strlen on the first parameter, otherwise   *             it trusts the given length (does not stop on NUL byte).   */  QMD5(const char* in, int len = -1);  /**   * @overload   *   * Same as above except it accepts a QByteArray as its argument.   */  QMD5(const QByteArray& a );  /**   * @overload   *   * Same as above except it accepts a QByteArray as its argument.   */  QMD5(const QCString& a );  /**   * Updates the message to be digested. Be sure to add all data   * before you read the digest. After reading the digest, you   * can <b>not</b> add more data!   *   * @param in     message to be added to digest   * @param len    the length of the given message.   */  void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); }  /**   * @overload   */  void update(const unsigned char* in, int len = -1);  /**   * @overload   *   * @param in     message to be added to the digest (QByteArray).   */  void update(const QByteArray& in );  /**   * @overload   *   * @param in     message to be added to the digest (QByteArray).   */  void update(const QCString& in );  /**   * @overload   *   * reads the data from an I/O device, i.e. from a file (QFile).   *   * NOTE that the file must be open for reading.   *   * @param file       a pointer to FILE as returned by calls like f{d,re}open   *   * @returns false if an error occured during reading.   */  bool update(QIODevice& file);  /**   * Calling this function will reset the calculated message digest.   * Use this method to perform another message digest calculation   * without recreating the QMD5 object.   */  void reset();  /**   * @return the raw representation of the digest   */  const Digest& rawDigest ();  /**   * Fills the given array with the binary representation of the   * message digest.   *   * Use this method if you do not want to worry about making   * copy of the digest once you obtain it.   *   * @param bin an array of 16 characters ( char[16] )   */  void rawDigest( QMD5::Digest& bin );  /**   * Returns the value of the calculated message digest in   * a hexadecimal representation.   */  QCString hexDigest ();  /**   * @overload   */  void hexDigest(QCString&);  /**   * Returns the value of the calculated message digest in   * a base64-encoded representation.   */  QCString base64Digest ();  /**   * returns true if the calculated digest for the given   * message matches the given one.   */  bool verify( const QMD5::Digest& digest);  /**   * @overload   */  bool verify(const QCString&);protected:  /**   *  Performs the real update work.  Note   *  that length is implied to be 64.   */  void transform( const unsigned char buffer[64] );  /**   * finalizes the digest   */  void finalize();private:  QMD5(const QMD5& u);  QMD5& operator=(const QMD5& md);  void init();  void encode( unsigned char* output, Q_UINT32 *in, Q_UINT32 len );  void decode( Q_UINT32 *output, const unsigned char* in, Q_UINT32 len );  Q_UINT32 rotate_left( Q_UINT32 x, Q_UINT32 n );  Q_UINT32 F( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );  Q_UINT32 G( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );  Q_UINT32 H( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );  Q_UINT32 I( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );  void FF( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,               Q_UINT32  s, Q_UINT32 ac );  void GG( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,                Q_UINT32 s, Q_UINT32 ac );  void HH( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,                Q_UINT32 s, Q_UINT32 ac );  void II( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,             Q_UINT32 s, Q_UINT32 ac );private:  Q_UINT32 m_state[4];  Q_UINT32 m_count[2];  Q_UINT8 m_buffer[64];  Digest m_digest;  bool m_finalized;  QMD5Private* d;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -