foobar2000 SDK  2015-08-03
hasher_md5.cpp
Go to the documentation of this file.
1 #include "foobar2000.h"
2 
4 {
5  assert(sizeof(GUID) == sizeof(hasher_md5_result));
6  GUID temp = * reinterpret_cast<const GUID*>(&param);
8  return temp;
9 }
10 
11 hasher_md5_result hasher_md5::process_single(const void * p_buffer,t_size p_bytes)
12 {
13  hasher_md5_state state;
14  initialize(state);
15  process(state,p_buffer,p_bytes);
16  return get_result(state);
17 }
18 
19 GUID hasher_md5::process_single_guid(const void * p_buffer,t_size p_bytes)
20 {
21  return guid_from_result(process_single(p_buffer,p_bytes));
22 }
23 
25 #if PFC_BYTE_ORDER_IS_BIG_ENDIAN
26  t_uint64 ret = 0;
27  for(int walk = 0; walk < 8; ++walk) {
28  ret |= (t_uint64)((t_uint8)m_data[walk] ^ (t_uint8)m_data[walk+8]) << (walk * 8);
29  }
30  return ret;
31 #else
32  const t_uint64 * v = reinterpret_cast<const t_uint64*>(&m_data);
33  return v[0] ^ v[1];
34 #endif
35 }
hasher_md5_result process_single(const void *p_buffer, t_size p_bytes)
Definition: hasher_md5.cpp:11
uint8_t t_uint8
Definition: int_types.h:9
Definition: pfc.h:71
uint64_t t_uint64
Definition: int_types.h:3
virtual hasher_md5_result get_result(const hasher_md5_state &p_state)=0
virtual void initialize(hasher_md5_state &p_state)=0
t_uint64 xorHalve() const
Definition: hasher_md5.cpp:24
void order_le_to_native_t(T &param)
size_t t_size
Definition: int_types.h:48
static GUID guid_from_result(const hasher_md5_result &param)
Definition: hasher_md5.cpp:3
virtual void process(hasher_md5_state &p_state, const void *p_buffer, t_size p_bytes)=0
GUID process_single_guid(const void *p_buffer, t_size p_bytes)
Definition: hasher_md5.cpp:19