mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
Simplify generation of sec-websocket-key
The result of `g()` is a random number, therefore it's not necessary to care about endianness in this case. Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
committed by
Vinnie Falco
parent
b8b04f8f39
commit
1635df0e11
@@ -4,6 +4,7 @@ Version 260:
|
|||||||
* Qualify calls to `beast::iequals` in basic_parser.ipp
|
* Qualify calls to `beast::iequals` in basic_parser.ipp
|
||||||
* More split compilation in websocket/detail/mask.hpp
|
* More split compilation in websocket/detail/mask.hpp
|
||||||
* Cleanup transitive includes in beast/core/detail/type_traits.hpp
|
* Cleanup transitive includes in beast/core/detail/type_traits.hpp
|
||||||
|
* Simplify generation of sec-websocket-key
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -27,18 +27,12 @@ void
|
|||||||
make_sec_ws_key(sec_ws_key_type& key)
|
make_sec_ws_key(sec_ws_key_type& key)
|
||||||
{
|
{
|
||||||
auto g = make_prng(true);
|
auto g = make_prng(true);
|
||||||
char a[16];
|
std::uint32_t a[4];
|
||||||
for(int i = 0; i < 16; i += 4)
|
for (auto& v : a)
|
||||||
{
|
v = g();
|
||||||
auto const v = g();
|
|
||||||
a[i ] = v & 0xff;
|
|
||||||
a[i+1] = (v >> 8) & 0xff;
|
|
||||||
a[i+2] = (v >> 16) & 0xff;
|
|
||||||
a[i+3] = (v >> 24) & 0xff;
|
|
||||||
}
|
|
||||||
key.resize(key.max_size());
|
key.resize(key.max_size());
|
||||||
key.resize(beast::detail::base64::encode(
|
key.resize(beast::detail::base64::encode(
|
||||||
key.data(), &a[0], 16));
|
key.data(), &a[0], sizeof(a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user