From 9bdb95c9e34cef640534e5e5a1e2225a80442000 Mon Sep 17 00:00:00 2001 From: HelenHuang <LinHuang@pollex.com.tw> Date: 星期四, 09 六月 2022 15:48:15 +0800 Subject: [PATCH] TODO#139894 [ footer -最下方說明與保經代合作 ] 文案修改 --- PAMapp/node_modules/loader-utils/lib/getHashDigest.js | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diff --git a/PAMapp/node_modules/loader-utils/lib/getHashDigest.js b/PAMapp/node_modules/loader-utils/lib/getHashDigest.js index bbc4e03..7098f06 100644 --- a/PAMapp/node_modules/loader-utils/lib/getHashDigest.js +++ b/PAMapp/node_modules/loader-utils/lib/getHashDigest.js @@ -39,11 +39,34 @@ return output; } +let createMd4 = undefined; +let BatchedHash = undefined; + function getHashDigest(buffer, hashType, digestType, maxLength) { - hashType = hashType || 'md5'; + hashType = hashType || 'md4'; maxLength = maxLength || 9999; - const hash = require('crypto').createHash(hashType); + let hash; + + try { + hash = require('crypto').createHash(hashType); + } catch (error) { + if (error.code === 'ERR_OSSL_EVP_UNSUPPORTED' && hashType === 'md4') { + if (createMd4 === undefined) { + createMd4 = require('./hash/md4'); + + if (BatchedHash === undefined) { + BatchedHash = require('./hash/BatchedHash'); + } + } + + hash = new BatchedHash(createMd4()); + } + + if (!hash) { + throw error; + } + } hash.update(buffer); @@ -54,8 +77,7 @@ digestType === 'base49' || digestType === 'base52' || digestType === 'base58' || - digestType === 'base62' || - digestType === 'base64' + digestType === 'base62' ) { return encodeBufferToBase(hash.digest(), digestType.substr(4)).substr( 0, -- Gitblit v1.8.0