UNPKG
@pr4j3sh/bitter
Version:
latest (1.0.4)
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
bittorrent client
github.com/pr4j3sh/bitter
pr4j3sh/bitter
@pr4j3sh/bitter
/
src
/
utils.js
14 lines
(10 loc)
•
233 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const
crypto =
require
(
"crypto"
);
const
{
Buffer
} =
require
(
"node:buffer"
);
let
id =
null
;
module
.
exports
.
genId
=
() =>
{
if
(!id) { id = crypto.
randomBytes
(
20
);
Buffer
.
from
(
"-BT0001-"
).
copy
(id,
0
); }
return
id; };