Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3486253
D6697.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
743 B
Referenced Files
None
Subscribers
None
D6697.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D6697: Reimplement generateRandomString using browser crypto module
Attached
Detach File
Event Timeline
Log In to Comment