libktorrent
2.2.0
src
util
sha1hash.h
1
/***************************************************************************
2
* Copyright (C) 2005 by Joris Guisson *
3
* joris.guisson@gmail.com *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
#ifndef BTSHA1HASH_H
21
#define BTSHA1HASH_H
22
23
#include <QByteArray>
24
#include <ktorrent_export.h>
25
#include "constants.h"
26
27
class
QString;
28
29
namespace
bt
30
{
31
class
Log;
32
40
class
KTORRENT_EXPORT
SHA1Hash
41
{
42
protected
:
43
Uint8 hash[20];
44
public
:
48
SHA1Hash
();
49
54
SHA1Hash
(
const
SHA1Hash
& other);
55
60
SHA1Hash
(
const
Uint8* h);
61
65
virtual
~SHA1Hash
();
66
68
Uint8 operator [] (
const
Uint32 idx)
const
{
return
idx < 20 ? hash[idx] : 0;}
69
74
SHA1Hash
& operator = (
const
SHA1Hash
& other);
75
81
bool
operator == (
const
SHA1Hash
& other)
const
;
82
88
bool
operator != (
const
SHA1Hash
& other)
const
{
return
!operator ==(other);}
89
96
static
SHA1Hash
generate
(
const
Uint8* data,Uint32 len);
97
102
QString
toString
()
const
;
103
108
QString
toURLString
()
const
;
109
114
const
Uint8*
getData
()
const
{
return
hash;}
115
122
KTORRENT_EXPORT
friend
Log
& operator << (
Log
& out,
const
SHA1Hash
& h);
123
124
131
KTORRENT_EXPORT
friend
SHA1Hash
operator ^ (
const
SHA1Hash
& a,
const
SHA1Hash
& b);
132
139
KTORRENT_EXPORT
friend
bool
operator < (
const
SHA1Hash
& a,
const
SHA1Hash
& b);
140
146
KTORRENT_EXPORT
friend
uint
qHash
(
const
SHA1Hash
&key);
147
151
QByteArray
toByteArray
()
const
;
152
};
153
154
}
155
156
#endif
bt::SHA1Hash::~SHA1Hash
virtual ~SHA1Hash()
bt::SHA1Hash::toString
QString toString() const
bt::Log
Class which writes messages to a logfile.
Definition:
log.h:77
bt::SHA1Hash::SHA1Hash
SHA1Hash(const SHA1Hash &other)
bt::SHA1Hash::SHA1Hash
SHA1Hash(const Uint8 *h)
bt::SHA1Hash::toByteArray
QByteArray toByteArray() const
bt::SHA1Hash
Stores a SHA1 hash.
Definition:
sha1hash.h:41
bt::SHA1Hash::toURLString
QString toURLString() const
bt::SHA1Hash::getData
const Uint8 * getData() const
Definition:
sha1hash.h:114
bt::SHA1Hash::SHA1Hash
SHA1Hash()
bt::SHA1Hash::qHash
KTORRENT_EXPORT friend uint qHash(const SHA1Hash &key)
bt::SHA1Hash::generate
static SHA1Hash generate(const Uint8 *data, Uint32 len)
Generated by
1.8.18