29 {
static std::string
_type(
"md5" );
return _type; }
32 {
static std::string
_type(
"sha" );
return _type; }
35 {
static std::string
_type(
"sha1" );
return _type; }
38 {
static std::string
_type(
"sha256" );
return _type; }
46 *
this =
CheckSum( std::string(), checksum );
51 , _checksum( checksum )
53 switch ( checksum.size() )
95 WAR <<
"Can't determine type of " << checksum.size() <<
" byte checksum '" <<
_checksum <<
"'" << endl;
103 std::string msg =
str::form (
_(
"Dubious type '%s' for %u byte checksum '%s'"),
120 if ( input_r.good() && ! type_r.empty() )
124 if ( ! input_r.eof() ||
_checksum.empty() )
142 std::ostringstream str;
151 return str << std::string(
"NoCheckSum");
154 return str << ( obj.
type().empty() ? std::string(
"UNKNOWN") : obj.
type() ) <<
'-' << obj.
checksum();
159 const std::string & type( obj.
type() );
162 if ( ! type.empty() ) str <<
" type=\"" << type <<
"\"";
166 str <<
">" <<
checksum <<
"</checksum>";
176 {
return ! ( lhs == rhs ); }
std::string digest()
get hex string representation of the digest
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
std::ostream & dumpAsXmlOn(std::ostream &str, const CheckSum &obj)
static const std::string & shaType()
std::string asString() const
static const std::string & sha256Type()
std::ostream & operator<<(std::ostream &str, const Exception &obj)
#define _(MSG)
Return translated text.
std::string checksum() const
std::string toLower(const std::string &s)
Return lowercase version of s.
std::string form(const char *format,...)
Printf style construction of std::string.
static const std::string & sha1Type()
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
bool operator!=(const CheckSum &lhs, const CheckSum &rhs)
CheckSum()
Default Ctor: empty checksum.
bool operator==(const CheckSum &lhs, const CheckSum &rhs)
static const std::string & md5Type()