Skip to content

Commit 9a6f65d

Browse files
Tony SæleJeremy Ong
authored andcommitted
strong_rand_bytes
1 parent f6892c8 commit 9a6f65d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/websocket_client.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ error_info(Handler, Reason, State) ->
241241
-spec generate_ws_key() ->
242242
binary().
243243
generate_ws_key() ->
244-
base64:encode(crypto:rand_bytes(16)).
244+
base64:encode(crypto:strong_rand_bytes(16)).
245245

246246
%% @doc Validate handshake response challenge
247247
-spec validate_handshake(HandshakeResponse :: binary(), Key :: binary()) -> {ok, binary()} | {error, term()}.
@@ -430,7 +430,7 @@ encode_frame({Type, Payload}) ->
430430
Opcode = websocket_req:name_to_opcode(Type),
431431
Len = iolist_size(Payload),
432432
BinLen = payload_length_to_binary(Len),
433-
MaskingKeyBin = crypto:rand_bytes(4),
433+
MaskingKeyBin = crypto:strong_rand_bytes(4),
434434
<< MaskingKey:32 >> = MaskingKeyBin,
435435
Header = << 1:1, 0:3, Opcode:4, 1:1, BinLen/bits, MaskingKeyBin/bits >>,
436436
MaskedPayload = mask_payload(MaskingKey, Payload),

0 commit comments

Comments
 (0)