Skip to content

Commit

Permalink
Merge pull request sanmiguel#56 from sanmiguel/mtc-crypto_strong_rand…
Browse files Browse the repository at this point in the history
…_bytes

Use crypto:strong_rand_bytes/1
  • Loading branch information
sanmiguel authored Jun 16, 2017
2 parents bfddfee + 9788008 commit f2204a5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wsc_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ encode_frame({Type, Payload}) ->
Opcode = websocket_req:name_to_opcode(Type),
Len = iolist_size(Payload),
BinLen = payload_length_to_binary(Len),
MaskingKeyBin = crypto:rand_bytes(4),
MaskingKeyBin = crypto:strong_rand_bytes(4),
<< MaskingKey:32 >> = MaskingKeyBin,
Header = << 1:1, 0:3, Opcode:4, 1:1, BinLen/bits, MaskingKeyBin/bits >>,
MaskedPayload = mask_payload(MaskingKey, Payload),
Expand Down Expand Up @@ -224,4 +224,4 @@ set_continuation_if_empty(WSReq, Opcode) ->
%% @doc Key sent in initial handshake
-spec generate_ws_key() -> binary().
generate_ws_key() ->
base64:encode(crypto:rand_bytes(16)).
base64:encode(crypto:strong_rand_bytes(16)).

0 comments on commit f2204a5

Please sign in to comment.