mirror of
https://github.com/denoland/deno.git
synced 2025-01-15 02:20:15 -05:00
ws: use crypto getRandomValues (denoland/deno_std#584)
Original: bc7dd3904b
This commit is contained in:
parent
eea856e341
commit
7213d9cc7f
1 changed files with 1 additions and 5 deletions
|
@ -189,11 +189,7 @@ export async function readFrame(buf: BufReader): Promise<WebSocketFrame> {
|
|||
|
||||
// Create client-to-server mask, random 32bit number
|
||||
function createMask(): Uint8Array {
|
||||
// TODO: use secure and immutable random function. Crypto.getRandomValues()
|
||||
const arr = Array.from({ length: 4 }).map(
|
||||
(): number => Math.round(Math.random() * 0xff)
|
||||
);
|
||||
return new Uint8Array(arr);
|
||||
return crypto.getRandomValues(new Uint8Array(4));
|
||||
}
|
||||
|
||||
class WebSocketImpl implements WebSocket {
|
||||
|
|
Loading…
Reference in a new issue