diff options
Diffstat (limited to 'src/util.cc')
| -rw-r--r-- | src/util.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc index ac2246c3..3d90ccaa 100644 --- a/src/util.cc +++ b/src/util.cc @@ -88,6 +88,17 @@ dcp::make_uuid () return string (buffer); } +string +dcp::make_digest (Data data) +{ + SHA_CTX sha; + SHA1_Init (&sha); + SHA1_Update (&sha, data.data().get(), data.size()); + byte_t byte_buffer[SHA_DIGEST_LENGTH]; + SHA1_Final (byte_buffer, &sha); + char digest[64]; + return Kumu::base64encode (byte_buffer, SHA_DIGEST_LENGTH, digest, 64); +} /** Create a digest for a file. * @param filename File name. |
