Mercurial > foo_out_sdl
diff foosdk/sdk/foobar2000/SDK/hasher_md5.cpp @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/foobar2000/SDK/hasher_md5.cpp Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,48 @@ +#include "foobar2000-sdk-pch.h" +#include "hasher_md5.h" + +GUID hasher_md5::guid_from_result(const hasher_md5_result & param) +{ + static_assert(sizeof(GUID) == sizeof(hasher_md5_result), "sanity"); + GUID temp = * reinterpret_cast<const GUID*>(¶m); + byte_order::order_le_to_native_t(temp); + return temp; +} + +GUID hasher_md5_result::asGUID() const { + return hasher_md5::guid_from_result( *this ); +} + +hasher_md5_result hasher_md5::process_single(const void * p_buffer,t_size p_bytes) +{ + hasher_md5_state state; + initialize(state); + process(state,p_buffer,p_bytes); + return get_result(state); +} + +GUID hasher_md5::process_single_guid(const void * p_buffer,t_size p_bytes) +{ + return guid_from_result(process_single(p_buffer,p_bytes)); +} + +t_uint64 hasher_md5_result::xorHalve() const { +#if PFC_BYTE_ORDER_IS_BIG_ENDIAN + t_uint64 ret = 0; + for(int walk = 0; walk < 8; ++walk) { + ret |= (t_uint64)((t_uint8)m_data[walk] ^ (t_uint8)m_data[walk+8]) << (walk * 8); + } + return ret; +#else + const t_uint64 * v = reinterpret_cast<const t_uint64*>(&m_data); + return v[0] ^ v[1]; +#endif +} + +pfc::string8 hasher_md5_result::asString() const { + return pfc::format_hexdump( this->m_data, sizeof(m_data), ""); +} + +GUID hasher_md5_result::toGUID() const { + return hasher_md5::guid_from_result( *this ); +}
