@@ -72,7 +72,6 @@ namespace hashlib {
7272 std::size_t padding_size = (buffer_size < 56 ) ? (56 - buffer_size) : (120 - buffer_size);
7373 update ({padding, padding_size});
7474 std::uint64_t bits = total_size * 8 ;
75- // 使用大端序填充长度
7675 for (std::size_t i = 0 ; i < 8 ; ++i) {
7776 padding[7 - i] = bits & 0xff ;
7877 bits >>= 8 ;
@@ -93,7 +92,7 @@ namespace hashlib {
9392 }
9493
9594 private:
96- void process_block_ (const byte* block) noexcept {
95+ auto process_block_ (const byte* block) noexcept -> void {
9796 static constexpr std::uint32_t k[64 ] = {
9897 0x428a2f98 , 0x71374491 , 0xb5c0fbcf , 0xe9b5dba5 ,
9998 0x3956c25b , 0x59f111f1 , 0x923f82a4 , 0xab1c5ed5 ,
@@ -115,15 +114,13 @@ namespace hashlib {
115114
116115 std::uint32_t w[64 ];
117116
118- // 使用大端序读取
119117 for (std::size_t i = 0 ; i < 16 ; ++i) {
120118 w[i] = (std::uint32_t (block[i * 4 ]) << 24 ) |
121119 (std::uint32_t (block[i * 4 + 1 ]) << 16 ) |
122120 (std::uint32_t (block[i * 4 + 2 ]) << 8 ) |
123121 (std::uint32_t (block[i * 4 + 3 ]));
124122 }
125123
126- // 消息调度
127124 for (std::size_t i = 16 ; i < 64 ; ++i) {
128125 const auto s0 = rotr32 (w[i-15 ], 7 ) ^ rotr32 (w[i-15 ], 18 ) ^ (w[i-15 ] >> 3 );
129126 const auto s1 = rotr32 (w[i-2 ], 17 ) ^ rotr32 (w[i-2 ], 19 ) ^ (w[i-2 ] >> 10 );
@@ -133,7 +130,6 @@ namespace hashlib {
133130 auto a = h_[0 ], b = h_[1 ], c = h_[2 ], d = h_[3 ],
134131 e = h_[4 ], f = h_[5 ], g = h_[6 ], h = h_[7 ];
135132
136- // 压缩函数主循环
137133 for (std::size_t i = 0 ; i < 64 ; ++i) {
138134 const auto S1 = rotr32 (e, 6 ) ^ rotr32 (e, 11 ) ^ rotr32 (e, 25 );
139135 const auto ch = (e & f) ^ ((~e) & g);
@@ -163,7 +159,7 @@ namespace hashlib {
163159 }
164160
165161 HASHLIB_ALWAYS_INLINE
166- static constexpr std:: uint32_t rotr32 (std::uint32_t x, int n) noexcept {
162+ static constexpr auto rotr32 (std::uint32_t x, int n) noexcept -> std::uint32_t {
167163 return (x >> n) | (x << (32 - n));
168164 }
169165
0 commit comments