diff options
author | louiz’ <louiz@louiz.org> | 2017-06-28 14:41:33 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-06-28 14:41:33 +0200 |
commit | 13a1ab1878fd6312aea485ded3f5bad59c36f17f (patch) | |
tree | 071b90523126d677f714cbf13346507f2e500d69 /louloulibs/utils/sha1.cpp | |
parent | a1349361d2c15929e8260536c9091f2a4c2048a4 (diff) | |
parent | 7e69d0387e85eeed10d605349feeba595c3fa0ee (diff) | |
download | biboumi-13a1ab1878fd6312aea485ded3f5bad59c36f17f.tar.gz biboumi-13a1ab1878fd6312aea485ded3f5bad59c36f17f.tar.bz2 biboumi-13a1ab1878fd6312aea485ded3f5bad59c36f17f.tar.xz biboumi-13a1ab1878fd6312aea485ded3f5bad59c36f17f.zip |
Merge remote-tracking branch 'remotes/debian/master' into debian
Diffstat (limited to 'louloulibs/utils/sha1.cpp')
-rw-r--r-- | louloulibs/utils/sha1.cpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/louloulibs/utils/sha1.cpp b/louloulibs/utils/sha1.cpp deleted file mode 100644 index 71ad18d..0000000 --- a/louloulibs/utils/sha1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include <utils/sha1.hpp> - -#include <louloulibs.h> - -#ifdef BOTAN_FOUND -# include <botan/hash.h> -# include <botan/hex.h> -#endif -#ifdef GCRYPT_FOUND -# include <gcrypt.h> -# include <vector> -# include <iomanip> -# include <sstream> -#endif - -std::string sha1(const std::string& input) -{ -#ifdef BOTAN_FOUND - auto sha1 = Botan::HashFunction::create_or_throw("SHA-1"); - sha1->update(input); - return Botan::hex_encode(sha1->final(), false); -#endif -#ifdef GCRYPT_FOUND - const auto hash_length = gcry_md_get_algo_dlen(GCRY_MD_SHA1); - std::vector<uint8_t> output(hash_length, {}); - gcry_md_hash_buffer(GCRY_MD_SHA1, output.data(), input.data(), input.size()); - std::ostringstream digest; - for (std::size_t i = 0; i < hash_length; i++) - digest << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(output[i]); - return digest.str(); -#endif -} |