Skip to content

Commit 41d4e57

Browse files
Merge pull request #229 from Sebastian-Webster/228-use-cryptorandomint-to-generate-port-number
Use crypto.randomInt for port generation
2 parents a30d209 + 032740f commit 41d4e57

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libraries/Port.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { randomInt } from "crypto"
2+
13
export function GenerateRandomPort() {
2-
return Math.floor(Math.random() * (65535 - 1024) + 1025)
4+
//Min is inclusive and max is exclusive. Inclusive range would be 1025 - 65535
5+
return randomInt(1025, 65536)
36
}

0 commit comments

Comments
 (0)