From 07521068c4e6de79d54e7b3ec049215ee8b85668 Mon Sep 17 00:00:00 2001 From: HorimotoYasuhiro Date: Sun, 16 Jul 2017 22:39:43 +0900 Subject: [PATCH] Improve convert to big-endian from little-endian (#1804) --- Foundation/src/SHA1Engine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Foundation/src/SHA1Engine.cpp b/Foundation/src/SHA1Engine.cpp index 7ea17df56e..5a2d7b578f 100644 --- a/Foundation/src/SHA1Engine.cpp +++ b/Foundation/src/SHA1Engine.cpp @@ -18,6 +18,7 @@ #include "Poco/SHA1Engine.h" +#include "Poco/ByteOrder.h" #include @@ -50,13 +51,12 @@ inline void SHA1Engine::byteReverse(UInt32* buffer, int byteCount) byteCount /= sizeof(UInt32); for(int count = 0; count < byteCount; count++) { - UInt32 value = (buffer[ count ] << 16) | (buffer[ count ] >> 16); - buffer[count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8); + buffer[count] = Poco::ByteOrder::toBigEndian(buffer[ count ]); } #endif // POCO_ARCH_LITTLE_ENDIAN } - + void SHA1Engine::updateImpl(const void* buffer_, std::size_t count) { const BYTE* buffer = (const BYTE*) buffer_;