Abstracted an sha1sum() function
This commit is contained in:
parent
b90ce78906
commit
93e0d8c67a
2 changed files with 11 additions and 6 deletions
10
src/utils.h
10
src/utils.h
|
|
@ -659,6 +659,16 @@ inline string to_hex(uint_least32_t * message_digest, const int len = 1)
|
||||||
return buf.str();
|
return buf.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline string sha1sum(const string& str)
|
||||||
|
{
|
||||||
|
SHA1 sha;
|
||||||
|
sha.Reset();
|
||||||
|
sha << str.c_str();
|
||||||
|
uint_least32_t message_digest[5];
|
||||||
|
sha.Result(message_digest);
|
||||||
|
return to_hex(message_digest, 5);
|
||||||
|
}
|
||||||
|
|
||||||
class push_xml
|
class push_xml
|
||||||
{
|
{
|
||||||
std::ostream& out;
|
std::ostream& out;
|
||||||
|
|
|
||||||
|
|
@ -454,12 +454,7 @@ string xact_t::idstring() const
|
||||||
|
|
||||||
string xact_t::id() const
|
string xact_t::id() const
|
||||||
{
|
{
|
||||||
SHA1 sha;
|
return sha1sum(idstring());
|
||||||
sha.Reset();
|
|
||||||
sha << idstring().c_str();
|
|
||||||
uint_least32_t message_digest[5];
|
|
||||||
sha.Result(message_digest);
|
|
||||||
return to_hex(message_digest, 5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue