sha1.cc
Go to the documentation of this file.
1 #include "cetlib/sha1.h"
2 
3 using cet::sha1;
4 
5 sha1::sha1()
6 {
7  reset();
8 }
9 
10 sha1::sha1(std::string const& mesg)
11 {
12  reset();
13  operator<<(mesg);
14 }
15 
16 sha1::sha1(char const mesg)
17 {
18  reset();
19  operator<<(mesg);
20 }
21 
22 void
24 {
25  SHA1_Init(&context);
26 }
27 
28 sha1&
30 {
31  auto data = reinterpret_cast<uchar const*>(&mesg[0]);
32  SHA1_Update(&context, data, mesg.size());
33  return *this;
34 }
35 
36 sha1&
37 sha1::operator<<(char const mesg)
38 {
39  auto data = reinterpret_cast<uchar const*>(&mesg);
40  SHA1_Update(&context, data, 1u);
41  return *this;
42 }
43 
46 {
47  digest_t result{{}};
48  SHA1_Final(&result[0], &context);
49  return result;
50 }
unsigned char uchar
Definition: sha1.h:29
static QCString result
std::string string
Definition: nybbler.cc:12
Definition: sha1.h:26
std::array< uchar, digest_sz > digest_t
Definition: sha1.h:30
sha1()
Definition: sha1.cc:5
SHA_CTX context
Definition: sha1.h:43
digest_t digest()
Definition: sha1.cc:45
sha1 & operator<<(std::string const &mesg)
Definition: sha1.cc:29
void reset()
Definition: sha1.cc:23