30 #ifndef SCIRE_hash_md5_HPP
31 #define SCIRE_hash_md5_HPP
83 template<
typename SzType =
size_t,
89 :
public IHashAlgo<SzType, Ui32t, ByteT, SByteT>
116 MD5(std::string message);
137 bool Update(
const ByteT* input, SzType lenght);
139 bool Update(
const SByteT* input, SzType lenght);
198 static Ui32t
F(Ui32t x, Ui32t y, Ui32t z)
200 return (
x&
y) | ((~
x)&
z);
215 static Ui32t
G(Ui32t x, Ui32t y, Ui32t z)
217 return (
x&
z) | (
y&(~
z));
220 static Ui32t
H(Ui32t x, Ui32t y, Ui32t z)
225 static Ui32t
I(Ui32t x, Ui32t y, Ui32t z)
227 return y ^ (
x | (~
z));
237 A = 0, B = 1, C = 2, D = 3,
239 S11 = 7, S21 = 5, S31 = 4, S41 = 6,
240 S12 = 12, S22 = 9, S32 = 11, S42 = 10,
241 S13 = 17, S23 = 14, S33 = 16, S43 = 15,
242 S14 = 22, S24 = 20, S34 = 23, S44 = 21,
248 static Ui32t rotateleft(Ui32t x, SzType n)
250 return (
x <<
n) | (
x >> (32 -
n));
256 static void FF(Ui32t &a, Ui32t b, Ui32t c, Ui32t d,
257 Ui32t x, Ui32t s, Ui32t ac)
262 static void GG(Ui32t &a, Ui32t b, Ui32t c, Ui32t d,
263 Ui32t x, Ui32t s, Ui32t ac)
268 static void HH(Ui32t &a, Ui32t b, Ui32t c, Ui32t d,
269 Ui32t x, Ui32t s, Ui32t ac)
274 static void II(Ui32t &a, Ui32t b, Ui32t c, Ui32t d,
275 Ui32t x, Ui32t s, Ui32t ac)
284 static void decode(Ui32t out[],
const ByteT input[], SzType len)
286 for (
unsigned int i = 0,
j = 0;
j <
len;
i++,
j += 4)
295 static void encode(ByteT out[],
const Ui32t input[], SzType len)
313 template<
typename SzType,
typename Ui32t,
typename ByteT,
typename SByteT>
326 MD5<SzType, Ui32t, ByteT, SByteT>::
335 MD5<SzType, Ui32t, ByteT, SByteT>::
345 MD5<SzType, Ui32t, ByteT, SByteT>::
376 <<
"A:" << (
unsigned int)
state[
A]
377 <<
" B:" << (
unsigned int)
state[
B]
378 <<
" C:" << (
unsigned int)
state[
C]
379 <<
" D:" << (
unsigned int)
state[
D];
395 void MD5<SzType, Ui32t, ByteT, SByteT>::
401 this->
state[0] = 0x67452301;
402 this->
state[1] = 0xefcdab89;
403 this->
state[2] = 0x98badcfe;
404 this->
state[3] = 0x10325476;
411 bool MD5<SzType, Ui32t, ByteT, SByteT>::
425 bool MD5<SzType, Ui32t, ByteT, SByteT>::
426 Update(
const SByteT * input, SzType length)
433 bool MD5<SzType, Ui32t, ByteT, SByteT>::
434 Update(
const ByteT * input, SzType inputLen)
470 void MD5<SzType, Ui32t, ByteT, SByteT>::
474 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
475 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
476 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
506 void MD5<SzType, Ui32t, ByteT, SByteT>::
std::ostream & operator<<(std::ostream &out, const MD5< SzType, Ui32t, ByteT, SByteT > &md5)
void Reset()
Reset object, similar to doing Init()
static Ui32t F(Ui32t x, Ui32t y, Ui32t z)
F(X,Y,Z) = XY v not(X) Z.
MD5 digest size in words (32bit)
Common interface for Hash Algorithms.
bool Update(const SByteT *input, SzType lenght)
MD5 block update operation.
MD5 process message in chunks each of 512bit.
bool Digest(ByteT digest[DigestSize_bytes]) const
get digest bytes in
std::string ToString() const
string reprsentation | fingerpring on finalize, else status words
static Ui32t G(Ui32t x, Ui32t y, Ui32t z)
G(X,Y,Z) = XZ v Y not(Z)
MD5 Message-Digest Algorithm.
scire/graph/gale_shapley.hpp
MD5 digest size in bytes.
block size in words (32bit)
MD5()
allocate MD5 context and init
std::string StatePhrase() const
String representation of Four State Words (ABCD)
MD5(std::string message)
Construct MD5 object with a string message.
void transform(const ByteT block[BlockSize_bytes])
the phenomenal transform function
static Ui32t I(Ui32t x, Ui32t y, Ui32t z)
I(X,Y,Z) = Y xor (X v not(Z))
static Ui32t H(Ui32t x, Ui32t y, Ui32t z)
H(X,Y,Z) = X xor Y xor Z.
void Init()
MD5 initialization.
bool Update(const ByteT *input, SzType lenght)
MD5 block update operation.
MD5(char message[])
Construct MD5 object with a string message.
std::string Fingerprint() const
fingerprint is the 128bit message-digest
void Final()
MD5 finalization.