diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-08-08 14:40:11 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-08-08 14:40:11 +0000 |
| commit | e85f9ccfd64b52419d47bd8f76c4b08eb2e0c422 (patch) | |
| tree | 89fa75c665af0d1866d5f001677c95215622ff7c /src/Checksum.h | |
| parent | 45f949c713d38e6e2141703cd9cb069c321a991f (diff) | |
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
Diffstat (limited to 'src/Checksum.h')
| -rw-r--r-- | src/Checksum.h | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/Checksum.h b/src/Checksum.h index eb1d5c34..54eea063 100644 --- a/src/Checksum.h +++ b/src/Checksum.h @@ -36,43 +36,39 @@ #define _D_CHECKSUM_H_ #include "common.h" -#ifdef ENABLE_MESSAGE_DIGEST -#include "messageDigest.h" class Checksum { private: - string md; - MessageDigestContext::DigestAlgo algo; + string _algo; + string _messageDigest; public: - Checksum(const string& md, MessageDigestContext::DigestAlgo algo): - md(md), - algo(algo) {} + // _messageDigest is ascii hexadecimal notation. + Checksum(const string& algo, const string& messageDigest): + _algo(algo), _messageDigest(messageDigest) {} Checksum(): - algo(DIGEST_ALGO_SHA1) {} + _algo("sha1") {} + ~Checksum() {} bool isEmpty() const { - return md.size() == 0; + return _messageDigest.size() == 0; } void setMessageDigest(const string& md) { - this->md = md; + this->_messageDigest = md; } const string& getMessageDigest() const { - return md; + return _messageDigest; } - void setDigestAlgo(MessageDigestContext::DigestAlgo algo) { - this->algo = algo; + void setAlgo(const string& algo) { + this->_algo = algo; } - const MessageDigestContext::DigestAlgo& getDigestAlgo() const { - return algo; + + const string& getAlgo() const { + return _algo; } }; -#else -class Checksum { -}; -#endif // ENABLE_MESSAGE_DIGEST typedef SharedHandle<Checksum> ChecksumHandle; |
