-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcrypto.js
36 lines (32 loc) · 1.3 KB
/
crypto.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* 解决node版本过高打包错误问题
*/
/** *
* - Bundling main process...node:internal/crypto/hash:71
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (D:\Desktop\2-electron-video\node_modules
\vue-cli-plugin-electron-builder\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\Desktop\2-electron-video\node_modules\
vue-cli-plugin-electron-builder\node_modules\webpack\lib\NormalModule.js:417:16)
*/
// github issues https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1885#issuecomment-1316735840
const crypto = require('crypto');
module.exports = function useCrypto() {
/**
* md4 algorithm is not available anymore in NodeJS 17+ (because of lib SSL 3).
* In that case, silently replace md4 by md5 algorithm.
*/
try {
crypto.createHash('md4');
} catch (e) {
console.warn('crypto.js: Crypto "md4" is not supported anymore by this Node version');
const origCreateHash = crypto.createHash;
crypto.createHash = (alg, opts) => {
return origCreateHash(alg === 'md4' ? 'md5' : alg, opts);
};
}
};