forked from teamhimeh/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwd_hash.h
42 lines (28 loc) · 792 Bytes
/
pwd_hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef PWD_HASH_H
#define PWD_HASH_H
#include <string.h>
#include "../macros.h"
#include "../simtypes.h"
class SHA1;
class pwd_hash_t
{
public:
pwd_hash_t() { clear(); }
void clear() { MEMZERO(hash); }
void set(SHA1& sha);
bool empty() const
{
for (uint8 const* i = hash; i != endof(hash); ++i) {
if (*i != 0) return false;
}
return true;
}
uint8& operator [](size_t const i) { return hash[i]; }
bool operator ==(const pwd_hash_t& o) const { return *this == o.hash; }
bool operator !=(const pwd_hash_t& o) const { return *this != o.hash; }
bool operator ==(uint8 const* const o) const { return memcmp(hash, o, sizeof(hash)) == 0; }
bool operator !=(uint8 const* const o) const { return !(*this == o); }
private:
uint8 hash[20];
};
#endif