libktorrent  2.2.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
bt::SHA1Hash Class Reference

Stores a SHA1 hash. More...

#include <sha1hash.h>

Inheritance diagram for bt::SHA1Hash:
Inheritance graph
[legend]

Public Member Functions

 SHA1Hash ()
 
 SHA1Hash (const SHA1Hash &other)
 
 SHA1Hash (const Uint8 *h)
 
virtual ~SHA1Hash ()
 
const Uint8 * getData () const
 
bool operator!= (const SHA1Hash &other) const
 
SHA1Hashoperator= (const SHA1Hash &other)
 
bool operator== (const SHA1Hash &other) const
 
Uint8 operator[] (const Uint32 idx) const
 Get the idx'th byte of the hash.
 
QByteArray toByteArray () const
 
QString toString () const
 
QString toURLString () const
 

Static Public Member Functions

static SHA1Hash generate (const Uint8 *data, Uint32 len)
 

Protected Attributes

Uint8 hash [20]
 

Friends

KTORRENT_EXPORT friend bool operator< (const SHA1Hash &a, const SHA1Hash &b)
 
KTORRENT_EXPORT friend Logoperator<< (Log &out, const SHA1Hash &h)
 
KTORRENT_EXPORT friend SHA1Hash operator^ (const SHA1Hash &a, const SHA1Hash &b)
 
KTORRENT_EXPORT friend uint qHash (const SHA1Hash &key)
 

Detailed Description

Author
Joris Guisson

This class keeps track of a SHA1 hash. A SHA1 hash is a 20 byte array of bytes.

Definition at line 40 of file sha1hash.h.

Constructor & Destructor Documentation

◆ SHA1Hash() [1/3]

bt::SHA1Hash::SHA1Hash ( )

Constructor, sets every byte in the hash to 0.

◆ SHA1Hash() [2/3]

bt::SHA1Hash::SHA1Hash ( const SHA1Hash other)

Copy constructor.

Parameters
otherHash to copy

◆ SHA1Hash() [3/3]

bt::SHA1Hash::SHA1Hash ( const Uint8 *  h)

Directly set the hash data.

Parameters
hThe hash data must be 20 bytes large

◆ ~SHA1Hash()

virtual bt::SHA1Hash::~SHA1Hash ( )
virtual

Destructor.

Member Function Documentation

◆ generate()

static SHA1Hash bt::SHA1Hash::generate ( const Uint8 *  data,
Uint32  len 
)
static

Generate an SHA1 hash from a bunch of data.

Parameters
dataThe data
lenSize in bytes of data
Returns
The generated SHA1 hash

◆ getData()

const Uint8* bt::SHA1Hash::getData ( ) const
inline

Directly get pointer to the data.

Returns
The data

Definition at line 114 of file sha1hash.h.

◆ operator!=()

bool bt::SHA1Hash::operator!= ( const SHA1Hash other) const
inline

Test whether another hash is not equal to this one.

Parameters
otherThe other hash
Returns
true if not equal, false otherwise

Definition at line 88 of file sha1hash.h.

◆ operator=()

SHA1Hash& bt::SHA1Hash::operator= ( const SHA1Hash other)

Assignment operator.

Parameters
otherHash to copy

◆ operator==()

bool bt::SHA1Hash::operator== ( const SHA1Hash other) const

Test whether another hash is equal to this one.

Parameters
otherThe other hash
Returns
true if equal, false otherwise

◆ toByteArray()

QByteArray bt::SHA1Hash::toByteArray ( ) const

Convert the hash to a byte array.

◆ toString()

QString bt::SHA1Hash::toString ( ) const

Convert the hash to a printable string.

Returns
The string

◆ toURLString()

QString bt::SHA1Hash::toURLString ( ) const

Convert the hash to a string, usable in http get requests.

Returns
The string

Friends And Related Function Documentation

◆ operator<

KTORRENT_EXPORT friend bool operator< ( const SHA1Hash a,
const SHA1Hash b 
)
friend

Function to compare 2 hashes

Parameters
aThe first hash
hThe second hash
Returns
whether a is smaller then b

◆ operator<<

KTORRENT_EXPORT friend Log& operator<< ( Log out,
const SHA1Hash h 
)
friend

Function to print a SHA1Hash to the Log.

Parameters
outThe Log
hThe hash
Returns
out

◆ operator^

KTORRENT_EXPORT friend SHA1Hash operator^ ( const SHA1Hash a,
const SHA1Hash b 
)
friend

XOR two SHA1Hashes

Parameters
aThe first hash
bThe second
Returns
a xor b

◆ qHash

KTORRENT_EXPORT friend uint qHash ( const SHA1Hash key)
friend

Function to support the use of SHA1Hash as QHash keys

Parameters
keySHA1Hash used to compute a hash key
Returns
hash key

The documentation for this class was generated from the following file: