Page MenuHomePhabricator

D6697.diff
No OneTemporary

D6697.diff

diff --git a/web/utils/text-utils.js b/web/utils/text-utils.js
--- a/web/utils/text-utils.js
+++ b/web/utils/text-utils.js
@@ -1,10 +1,14 @@
// @flow
-import crypto from 'crypto';
import invariant from 'invariant';
let canvas;
+declare var crypto: {
+ getRandomValues<NumArray: $TypedArray>(typedArray: NumArray): NumArray,
+ ...
+};
+
function calculateMaxTextWidth(
texts: $ReadOnlyArray<string>,
font: string,
@@ -46,7 +50,8 @@
let str = '';
while (str.length < length) {
- const rand = crypto.randomBytes(drawBytes);
+ const rand = new Uint8Array(drawBytes);
+ crypto.getRandomValues(rand);
for (let i = 0; str.length < length && i < drawBytes; i++) {
if (rand[i] < validByteUpperBound) {

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 4:09 AM (21 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675239
Default Alt Text
D6697.diff (743 B)

Event Timeline