Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
joedb_sha256sum.cpp
Go to the documentation of this file.
3
4#include <iostream>
5#include <iomanip>
6
7/////////////////////////////////////////////////////////////////////////////
8int main(int argc, char **argv)
9/////////////////////////////////////////////////////////////////////////////
10{
11 std::cout << std::hex;
12 std::cout << std::setfill('0');
13
14 bool fast = false;
15 int arg_start = 1;
16
17 if (argc > 1 && argv[1] == std::string("--fast"))
18 {
19 fast = true;
20 arg_start++;
21 }
22
23 for (int arg_index = arg_start; arg_index < argc; arg_index++)
24 {
25 const char * const file_name = argv[arg_index];
26
27 try
28 {
30
31 const joedb::SHA_256::Hash hash = fast ?
32 joedb::File_Hasher::get_fast_hash(file, 0, file.get_size()) :
34
35 for (uint32_t i = 0; i < 8; i++)
36 std::cout << std::setw(8) << hash[i];
37 std::cout << " " << file_name << '\n';
38 }
39 catch (const joedb::Exception &e)
40 {
41 std::cout << file_name << ": Error: " << e.what() << '\n';
42 }
43 }
44
45 return 0;
46}
static SHA_256::Hash get_fast_hash(Buffered_File &file, int64_t start, int64_t size)
static SHA_256::Hash get_hash(Buffered_File &file, int64_t start, int64_t size)
std::array< uint32_t, 8 > Hash
Definition SHA_256.h:60
int main()
@ read_existing
fails if does not exist
JOEDB_FILE File
Definition File.h:25