Language: JavaScript
Label: safe
CWE: CWE-331 \u2014 Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.

Code:
    NodeCryptography.prototype.encryptFile = function (key, file, File) {
        return __awaiter(this, void 0, void 0, function () {
            var bKey, _a, _b, _c, _d;
            var _e, _f;
            return __generator(this, function (_g) {
                switch (_g.label) {
                    case 0:
                        bKey = this.getKey(key);
                        if (!(file.data instanceof Buffer)) return [3 /*break*/, 2];
                        if (file.data.byteLength <= 0)
                            throw new Error('encryption error. empty content');
                        _b = (_a = File).create;
                        _e = {
                            name: file.name,
                            mimeType: 'application/octet-stream'
                        };
                        return [4 /*yield*/, this.encryptBuffer(bKey, file.data)];
                    case 1: return [2 /*return*/, _b.apply(_a, [(_e.data = _g.sent(),
                                _e)])];
                    case 2:
                        if (!(file.data instanceof stream_1.Readable)) return [3 /*break*/, 4];
                        if (file.contentLength === 0)
                            throw new Error('encryption error. empty content');
                        _d = (_c = File).create;
                        _f = {
                            name: file.name,
                            mimeType: 'application/octet-stream'
                        };
                        return [4 /*yield*/, this.encryptStream(bKey, file.data)];
                    case 3: return [2 /*return*/, _d.apply(_c, [(_f.stream = _g.sent(),
                                _f)])];
                    case 4: throw new Error('Cannot encrypt this file. In Node.js file encryption supports only string, Buffer or Stream.');
                }
            });
        });
    };