Search code examples
c++sha1

sha1 function in cpp (C++)


Ill start by saying I dont know anything about c++ and I googled, there is nothing that can make me understand how to use SHA1 in C++. found this one though Objective C: SHA1 but its about objective c im not sure it is the same.

I need to do the following:

I habve a lot of files, i compile them by doing ./make.sh and in one file called server.cpp I need to SHA1 info_hash thats inserted in this part:

Csql_query(m_database, "insert into @files (info_hash, mtime, ctime)
 values (?, unix_timestamp(), unix_timestamp())").p(i.first).execute();

so I kinda think I need to do the following sha1(?). "?" isnt info_hash i need. i think it generates somewhere and "?" is a variable.

so please dont tell me to add any classes or something else, because i do NOT understand how to do that, if i need to add something in the beggining of the file, please tell me so.


Solution

  • A good library for SHA1 and other functions is cryptopp.

    Here is another question where the answer is cryptopp: Fast Cross-Platform C/C++ Hashing Library