"Fossies" - the Fresh Open Source Software Archive

Member "tcpflow-1.6.1/src/scan_md5.cpp" (19 Feb 2021, 1108 Bytes) of package /linux/misc/tcpflow-1.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "scan_md5.cpp" see the Fossies "Dox" file reference documentation.

    1 /**
    2  *
    3  * scan_md5:
    4  * plug-in demonstration that shows how to write a simple plug-in scanner that calculates
    5  * the MD5 of each file..
    6  */
    7 
    8 #include "config.h"
    9 #include "bulk_extractor_i.h"
   10 #include "dfxml/src/hash_t.h"
   11 
   12 #include <iostream>
   13 #include <sys/types.h>
   14 
   15 
   16 extern "C"
   17 void  scan_md5(const class scanner_params &sp,const recursion_control_block &rcb)
   18 {
   19 
   20     if(sp.sp_version!=scanner_params::CURRENT_SP_VERSION){
   21     std::cerr << "scan_md5 requires sp version " << scanner_params::CURRENT_SP_VERSION << "; "
   22           << "got version " << sp.sp_version << "\n";
   23     exit(1);
   24     }
   25 
   26     if(sp.phase==scanner_params::PHASE_STARTUP){
   27     sp.info->name  = "md5";
   28     sp.info->flags = scanner_info::SCANNER_DISABLED;
   29         return;     /* No feature files created */
   30     }
   31 
   32 #ifdef HAVE_EVP_GET_DIGESTBYNAME
   33     if(sp.phase==scanner_params::PHASE_SCAN){
   34     static const std::string hash0("<hashdigest type='MD5'>");
   35     static const std::string hash1("</hashdigest>");
   36     if(sp.sxml){
   37             (*sp.sxml) << hash0 << md5_generator::hash_buf(sp.sbuf.buf,sp.sbuf.bufsize).hexdigest() << hash1;
   38         }
   39     return;
   40     }
   41 #endif
   42 }