diff options
| author | 2010-04-21 15:18:00 +0000 | |
|---|---|---|
| committer | 2010-04-21 15:18:00 +0000 | |
| commit | d74c14210629cdefe2ec4d3a5cd5a732f477f28b (patch) | |
| tree | 31cb1c8fad684f3cd05cdf80969f0a2c9ddde40d /src/modules/file/libkvifile.cpp | |
| parent | one more (diff) | |
| download | KVIrc-d74c14210629cdefe2ec4d3a5cd5a732f477f28b.tar.gz KVIrc-d74c14210629cdefe2ec4d3a5cd5a732f477f28b.tar.bz2 KVIrc-d74c14210629cdefe2ec4d3a5cd5a732f477f28b.zip | |
[KVIrc] $file.digest: Enable the Crypto++ code path.
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4283 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/file/libkvifile.cpp')
| -rw-r--r-- | src/modules/file/libkvifile.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/modules/file/libkvifile.cpp b/src/modules/file/libkvifile.cpp index 8636ebfa2..4858fc37b 100644 --- a/src/modules/file/libkvifile.cpp +++ b/src/modules/file/libkvifile.cpp @@ -40,7 +40,6 @@ #if defined(COMPILE_SSL_SUPPORT) && !defined(COMPILE_NO_EMBEDDED_CODE) // The current implementation #include <openssl/evp.h> -/* #elif defined(COMPILE_NO_EMBEDDED_CODE) // The preferred new implementation (until QCryptographicHash supports all // hashes we want). @@ -57,13 +56,14 @@ // Encoding #include <cryptopp/hex.h> // additional + #include <cryptopp/files.h> #include <string> // template function template <typename T> - std::string CryptoPpStrHash(std::string szMessage){ + std::string CryptoPpFileHash(std::string szFileName){ T hash; std::string szDigest; - CryptoPP::StringSource(szMessage, + CryptoPP::FileSource(szFileName.c_str(), true, new CryptoPP::HashFilter( hash, @@ -74,7 +74,6 @@ ); return szDigest; } -*/ #else // The fallback we can always use, but with very limited set of // functionality. @@ -1265,7 +1264,6 @@ static bool file_kvs_fnc_digest(KviKvsModuleFunctionCall * c) #endif szResult.append(cBuffer); } -/* #elif defined(COMPILE_NO_EMBEDDED_CODE) // Crypto++ implementation std::string szDigest; @@ -1273,50 +1271,49 @@ static bool file_kvs_fnc_digest(KviKvsModuleFunctionCall * c) if(szAlgo.toLower() == "sha1" || szAlgo.toLower() == "sha") { - szDigest = CryptoPpStrHash<CryptoPP::SHA1>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::SHA1>(szMsg); } else if(szAlgo.toLower() == "sha224") { - szDigest = CryptoPpStrHash<CryptoPP::SHA224>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::SHA224>(szMsg); } else if(szAlgo.toLower() == "sha256") { - szDigest = CryptoPpStrHash<CryptoPP::SHA256>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::SHA256>(szMsg); } else if(szAlgo.toLower() == "sha384") { - szDigest = CryptoPpStrHash<CryptoPP::SHA384>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::SHA384>(szMsg); } else if(szAlgo.toLower() == "sha512") { - szDigest = CryptoPpStrHash<CryptoPP::SHA512>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::SHA512>(szMsg); } else if(szAlgo.toLower() == "ripemd128") { - szDigest = CryptoPpStrHash<CryptoPP::RIPEMD128>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::RIPEMD128>(szMsg); } else if(szAlgo.toLower() == "ripemd160") { - szDigest = CryptoPpStrHash<CryptoPP::RIPEMD160>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::RIPEMD160>(szMsg); } else if(szAlgo.toLower() == "ripemd256") { - szDigest = CryptoPpStrHash<CryptoPP::RIPEMD256>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::RIPEMD256>(szMsg); } else if(szAlgo.toLower() == "ripemd320") { - szDigest = CryptoPpStrHash<CryptoPP::RIPEMD320>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::RIPEMD320>(szMsg); } else if(szAlgo.toLower() == "crc32") { - szDigest = CryptoPpStrHash<CryptoPP::CRC32>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::CRC32>(szMsg); } else if(szAlgo.toLower() == "md2") { - szDigest = CryptoPpStrHash<CryptoPP::Weak::MD2>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::Weak::MD2>(szMsg); } else if(szAlgo.toLower() == "md4") { - szDigest = CryptoPpStrHash<CryptoPP::Weak::MD4>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::Weak::MD4>(szMsg); } else if(szAlgo.toLower() == "md5") { - szDigest = CryptoPpStrHash<CryptoPP::Weak::MD5>(szMsg); + szDigest = CryptoPpFileHash<CryptoPP::Weak::MD5>(szMsg); } else { c->warning(__tr2qs("Unsupported message digest.")); return true; } szResult.append(szDigest.c_str()); -*/ #else // fall back to QCryptographicHash QCryptographicHash::Algorithm qAlgo; if(szType.toLower() == "sha1") |
