Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:34

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 #pragma once
0021 
0022 /**
0023 SDigest
0024 ========
0025 
0026 MD5 based hexdigest machinery, used throughout Opticks.
0027 Allows incremental update building of the digest.
0028 
0029 
0030 DevNotes
0031 ----------
0032    
0033 * http://stackoverflow.com/questions/7627723/how-to-create-a-md5-hash-of-a-string-in-c
0034 * hails from env/base/hash/md5digest.h
0035 
0036 **/
0037 
0038 
0039 #include "sdigest.h"
0040 #include <string>
0041 #include <vector>
0042 #include "plog/Severity.h"
0043 #include "SYSRAP_API_EXPORT.hh"
0044 
0045 class SYSRAP_API SDigest 
0046 {
0047        static const plog::Severity LEVEL ;    
0048    public:
0049        static const char* hexchar ; 
0050        static bool IsDigest(const char* s);
0051 
0052        static std::string DigestPathInByteRange(const char* path, int i0, int i1, unsigned bufsize=8192); 
0053        static std::string DigestPath(const char* path, unsigned bufsize=8192);
0054        static std::string DigestPath2(const char* path);
0055 
0056        static const char* md5digest_( const char* buffer, int len );
0057        static std::string md5digest( const char* buffer, int len );
0058        static std::string digest( void* buffer, int len );
0059        static std::string digest( std::vector<std::string>& ss);
0060        static std::string digest_skipdupe( std::vector<std::string>& ss);
0061 
0062        static std::string Buffer(const char *buffer, int length) ; 
0063 
0064    public:
0065        SDigest();
0066        virtual ~SDigest();
0067    public:
0068        void update( char* buffer, int length);
0069        void update_str( const char* str );
0070        void update( const std::string& str );
0071        char* finalize();
0072    private:
0073 
0074 #if defined(__GNUC__) || defined(__clang__)
0075 #pragma GCC diagnostic push
0076 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0077 #endif
0078        MD5_CTX m_ctx ;
0079 #if defined(__GNUC__) || defined(__clang__)
0080 #pragma GCC diagnostic pop
0081 #endif
0082 
0083 
0084 };
0085 
0086 
0087 
0088