Skip to content

Commit 9cf81fe

Browse files
committed
make the use of sha256 alg conditional to avoid performance impact for non-FIPS systems
1 parent 62ded09 commit 9cf81fe

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/vue2-jest/lib/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const crypto = require('crypto')
22
const babelJest = require('babel-jest').default
3+
4+
// get FIPS status and set hash algorithm accordingly
5+
const isFips = crypto.getFips ? crypto.getFips() : false
6+
const hashAlgorithm = isFips ? 'sha256' : 'md5'
7+
38
module.exports = {
49
process: require('./process'),
510
getCacheKey: function getCacheKey(
@@ -8,7 +13,7 @@ module.exports = {
813
{ config, configString, instrument, rootDir }
914
) {
1015
return crypto
11-
.createHash('sha256')
16+
.createHash(hashAlgorithm)
1217
.update(
1318
babelJest.createTransformer().getCacheKey(fileData, filename, {
1419
config,

packages/vue3-jest/lib/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const crypto = require('crypto')
22
const babelJest = require('babel-jest').default
3+
4+
// get FIPS status and set hash algorithm accordingly
5+
const isFips = crypto.getFips ? crypto.getFips() : false
6+
const hashAlgorithm = isFips ? 'sha256' : 'md5'
7+
38
module.exports = {
49
process: require('./process'),
510
getCacheKey: function getCacheKey(
@@ -8,7 +13,7 @@ module.exports = {
813
{ config, configString, instrument, rootDir }
914
) {
1015
return crypto
11-
.createHash('sha256')
16+
.createHash(hashAlgorithm)
1217
.update(
1318
babelJest.createTransformer().getCacheKey(fileData, filename, {
1419
config,

0 commit comments

Comments
 (0)