Eneboo - Documentación para desarrolladores
src/flbase/FLSha1.h
Ir a la documentación de este archivo.
00001 /***************************************************************************
00002                                FLSha1.h
00003                           -------------------
00004  begin                : lun ago 02 2004
00005  copyright            : (C) 2004-2005 by InfoSiAL, S.L.
00006  email                : mail@infosial.com
00007 ***************************************************************************/
00008 /***************************************************************************
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; version 2 of the License.               *
00012  ***************************************************************************/
00013 /***************************************************************************
00014    Este  programa es software libre. Puede redistribuirlo y/o modificarlo
00015    bajo  los  trminos  de  la  Licencia  Pblica General de GNU   en  su
00016    versin 2, publicada  por  la  Free  Software Foundation.
00017  ***************************************************************************/
00018 
00019 #ifndef FLSHA1_H
00020 #define FLSHA1_H
00021 
00022 #include <stdio.h>  // Needed for file access
00023 #include <memory.h> // Needed for memset and memcpy
00024 #include <string.h> // Needed for strcat and strcpy
00025 
00026 #include <qglobal.h>
00027 
00028 // If you're compiling big endian, just comment out the following line
00029 #define SHA1_LITTLE_ENDIAN
00030 
00031 typedef union {
00032   Q_UINT8 c[ 64 ];
00033   Q_UINT32 l[ 16 ];
00034 } SHA1_WORKSPACE_BLOCK;
00035 
00036 class FL_EXPORT FLSha1
00037 {
00038 public:
00039   // Two different formats for ReportHash(...)
00040   enum {
00041     REPORT_HEX = 0,
00042     REPORT_DIGIT = 1
00043   };
00044 
00045   // Constructor and Destructor
00046   FLSha1();
00047   virtual ~FLSha1();
00048 
00049   Q_UINT32 m_state[ 5 ];
00050   Q_UINT32 m_count[ 2 ];
00051   Q_UINT8 m_buffer[ 64 ];
00052   Q_UINT8 m_digest[ 20 ];
00053 
00054   void Reset();
00055 
00056   // Update the hash value
00057   void Update(Q_UINT8 *data, unsigned int len);
00058   bool HashFile(char *szFileName);
00059 
00060   // Finalize hash and report
00061   void Final();
00062   void ReportHash(char *szReport, Q_UINT8 uReportType = REPORT_HEX);
00063   void GetHash(Q_UINT8 *uDest);
00064 
00065 private:
00066   // Private SHA-1 transformation
00067   void Transform(Q_UINT32 state[ 5 ], Q_UINT8 buffer[ 64 ]);
00068 
00069   // Member variables
00070   Q_UINT8 m_workspace[ 64 ];
00071   SHA1_WORKSPACE_BLOCK *m_block; // SHA1 pointer to the byte array above
00072 };
00073 
00074 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'