Skip to content

Commit e777728

Browse files
committed
Add createBoundary.browser.ts
1 parent 1f6186c commit e777728

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/util/createBoundary.browser.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Generates a boundary string of given length.
3+
*/
4+
function createBoundary(length: number): string {
5+
const octets = new Uint8Array(length)
6+
7+
crypto.getRandomValues(octets)
8+
9+
return [...octets]
10+
.map<string>(octet => octet.toString(16).padStart(2, "0"))
11+
.join("")
12+
}
13+
14+
export default createBoundary

0 commit comments

Comments
 (0)