Skip to content

Commit 9596418

Browse files
Merge pull request from GHSA-3f99-hvg4-qjwj
* fix double String.fromCharCode * use crypto module if available Co-authored-by: Julian Gruber <[email protected]>
1 parent 87c62f2 commit 9596418

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,11 @@ util.createBuffer = function(input, encoding) {
756756
*/
757757

758758
var prng = forge.prng = {};
759-
var crypto = null;
759+
760+
var crypto;
761+
try {
762+
crypto = require('crypto');
763+
} catch (_) {}
760764

761765
prng.create = function(plugin) {
762766
var ctx = {
@@ -1005,7 +1009,7 @@ prng.create = function(plugin) {
10051009
// throw in more pseudo random
10061010
next = seed >>> (i << 3);
10071011
next ^= Math.floor(Math.random() * 0xFF);
1008-
b.putByte(String.fromCharCode(next & 0xFF));
1012+
b.putByte(next & 0xFF);
10091013
}
10101014
}
10111015
}

0 commit comments

Comments
 (0)