00001 /* Copyright 2009 Andreas Gölzer 00002 00003 This file is part of readESM. 00004 00005 readESM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 00006 00007 readESM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00008 00009 You should have received a copy of the GNU General Public License along with readESM. If not, see <http://www.gnu.org/licenses/>. */ 00010 #ifndef SHA1_H 00011 #define SHA1_H SHA1_H 00012 00013 #include <vector> 00014 #include <gcrypt.h> 00015 00016 bool checkSHA1match(const unsigned char* text, int textlength, const unsigned char* hash){ 00017 std::vector<unsigned char> buffer(20); 00018 gcry_md_hash_buffer(GCRY_MD_SHA1, &buffer[0], text, textlength); 00019 bool cmp = true; 00020 for(int j = 0; cmp && j < 20; ++j){ 00021 cmp = (hash[j] == buffer[j]); 00022 } 00023 return cmp; 00024 } 00025 00026 #endif