diff options
Diffstat (limited to 'src/sha1.cpp')
-rw-r--r-- | src/sha1.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sha1.cpp b/src/sha1.cpp new file mode 100644 index 0000000..1d99abd --- /dev/null +++ b/src/sha1.cpp @@ -0,0 +1,17 @@ +#include "sha1.h" + +namespace Multihash { + SHA1::SHA1(Hash* n) : Hash(n) { + SHA1_Init(&sha1_ctx); + } + + void SHA1::hash_update(const char* data, int length) { + SHA1_Update(&sha1_ctx, data, length); + } + + std::string SHA1::hash_digest() { + char digest[20]; + SHA1_Final((unsigned char*)digest, &sha1_ctx); + return Hex::hex(digest, 20); + } +} |