|
|
|||
File indexing completed on 2026-06-02 08:51:49
0001 #ifndef CRYPTOGRAPHIC_HASH_SERVICE_H 0002 #define CRYPTOGRAPHIC_HASH_SERVICE_H 0003 0004 /** 0005 * @file CryptographicHashService.h 0006 * @author Bryan BERTHOU (SPhN / CEA Saclay) 0007 * @date March 24, 2016 0008 * @version 1.0 0009 */ 0010 0011 #include <string> 0012 0013 #include "../../ServiceObject.h" 0014 0015 namespace PARTONS { 0016 0017 class CryptographicHashI; 0018 0019 /** 0020 * @class CryptographicHashService 0021 * 0022 * @brief Service for generation of hash values. 0023 * 0024 * This service is used to generate hash values for input strings of characters. The default generator is based on Qt4 library, see Qt4CryptographicHash class. 0025 * The usage of this service is demonstrated by the following example: 0026 \code{.cpp} 0027 //retrieve CryptographicHashService 0028 CryptographicHashService* pCryptographicHashService = Partons::getInstance()->getServiceObjectRegistry()->getCryptographicHashService(); 0029 0030 //generate hash value for given string of characters 0031 std::string inputString = "the quick brown fox jumps over the lazy dog"; 0032 std::string hashValue = pCryptographicHashService->generateSHA1HashSum(inputString); 0033 0034 //print result 0035 Partons::getInstance()->getLoggerManager()->info("example", __func__, ElemUtils::Formatter() << "SHA1 hash sum for string '" << inputString << "' is " << hashValue); 0036 \endcode 0037 which gives via Logger: 0038 \code 0039 14-06-2017 09:54:08 [INFO] (example::main) SHA1 hash sum for string 'the quick brown fox jumps over the lazy dog' is 16312751ef9307c3fd1afbcb993cdc80464ba0f1 0040 \endcode 0041 */ 0042 class CryptographicHashService: public ServiceObject { 0043 0044 public: 0045 0046 /** 0047 * Unique ID to automatically register the class in the registry. 0048 */ 0049 static const unsigned int classId; 0050 0051 /** 0052 * Constructor. 0053 * @param className Name of class. 0054 */ 0055 CryptographicHashService(const std::string &className); 0056 0057 /** 0058 * Destructor. 0059 */ 0060 virtual ~CryptographicHashService(); 0061 0062 virtual void computeTask(Task &task); 0063 0064 /** 0065 * Generate SHA-1 hash value for a given string of characters. 0066 * @param string Input string. 0067 */ 0068 std::string generateSHA1HashSum(const std::string &string) const; 0069 0070 private: 0071 0072 /** 0073 * Pointer to object used to generate hash values. 0074 */ 0075 CryptographicHashI* m_pCryptographicHashI; 0076 }; 0077 0078 } /* namespace PARTONS */ 0079 0080 #endif /* CRYPTOGRAPHIC_HASH_SERVICE_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|