Skip to content

Commit

Permalink
Merge pull request #6549 from webpack/md4_hash
Browse files Browse the repository at this point in the history
Use MD4 for hashing
  • Loading branch information
sokra committed Feb 24, 2018
2 parents 0e1f9c6 + 40ee8c7 commit 6e175bc
Show file tree
Hide file tree
Showing 41 changed files with 125 additions and 121 deletions.
2 changes: 1 addition & 1 deletion lib/HashedModuleIdsPlugin.js
Expand Up @@ -14,7 +14,7 @@ class HashedModuleIdsPlugin {

this.options = Object.assign({
context: null,
hashFunction: "md5",
hashFunction: "md4",
hashDigest: "base64",
hashDigestLength: 4
}, options);
Expand Down
2 changes: 1 addition & 1 deletion lib/ModuleFilenameHelpers.js
Expand Up @@ -42,7 +42,7 @@ const getBefore = (str, token) => {
};

const getHash = str => {
const hash = createHash("md5");
const hash = createHash("md4");
hash.update(str);
return hash.digest("hex").substr(0, 4);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/SourceMapDevToolPlugin.js
Expand Up @@ -211,7 +211,7 @@ class SourceMapDevToolPlugin {
basename: basename(filename)
});
if(sourceMapFile.includes("[contenthash]")) {
sourceMapFile = sourceMapFile.replace(/\[contenthash\]/g, createHash("md5").update(sourceMapString).digest("hex"));
sourceMapFile = sourceMapFile.replace(/\[contenthash\]/g, createHash("md4").update(sourceMapString).digest("hex"));
}
const sourceMapUrl = options.publicPath ? options.publicPath + sourceMapFile.replace(/\\/g, "/") : path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/");
if(currentSourceMappingURLComment !== false) {
Expand Down
2 changes: 1 addition & 1 deletion lib/WebpackOptionsDefaulter.js
Expand Up @@ -125,7 +125,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("output.crossOriginLoading", false);
this.set("output.jsonpScriptType", false);
this.set("output.chunkLoadTimeout", 120000);
this.set("output.hashFunction", "md5");
this.set("output.hashFunction", "md4");
this.set("output.hashDigest", "hex");
this.set("output.hashDigestLength", 20);
this.set("output.devtoolLineToLine", false);
Expand Down
2 changes: 1 addition & 1 deletion lib/optimize/ConcatenatedModule.js
Expand Up @@ -361,7 +361,7 @@ class ConcatenatedModule extends Module {
orderedConcatenationListIdentifiers += " ";
}
}
const hash = createHash("md5");
const hash = createHash("md4");
hash.update(orderedConcatenationListIdentifiers);
return this.rootModule.identifier() + " " + hash.digest("hex");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/optimize/SplitChunksPlugin.js
Expand Up @@ -10,7 +10,7 @@ const GraphHelpers = require("../GraphHelpers");
const isSubset = require("../util/SetHelpers").isSubset;

const hashFilename = (name) => {
return crypto.createHash("md5").update(name).digest("hex").slice(0, 8);
return crypto.createHash("md4").update(name).digest("hex").slice(0, 8);
};

const sortByIdentifier = (a, b) => {
Expand Down
42 changes: 21 additions & 21 deletions test/statsCases/aggressive-splitting-entry/expected.txt
@@ -1,53 +1,53 @@
Hash: 1d3bfcee111df03fa6251d3bfcee111df03fa625
Hash: a82dbd8d6c7a22df1cafa82dbd8d6c7a22df1caf
Child fitting:
Hash: 1d3bfcee111df03fa625
Hash: a82dbd8d6c7a22df1caf
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
706f97eb6a2b8fb1a17e.js 1.05 KiB 0 [emitted]
a65f8652fd07c12d0049.js 9.92 KiB 1 [emitted]
4c485a9e1dc58eedfbd1.js 1.94 KiB 2 [emitted]
337c857e3e34cc5ef72d.js 1.94 KiB 3 [emitted]
Entrypoint main = 4c485a9e1dc58eedfbd1.js 337c857e3e34cc5ef72d.js a65f8652fd07c12d0049.js
chunk {0} 706f97eb6a2b8fb1a17e.js 916 bytes <{1}> <{2}> <{3}>
fb95acf7c457672e70d0.js 1.05 KiB 0 [emitted]
a1e683753eca705a0882.js 9.92 KiB 1 [emitted]
d43339a3d0f86c6b8d90.js 1.94 KiB 2 [emitted]
6c7fb52c5514dbfbf094.js 1.94 KiB 3 [emitted]
Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js
chunk {0} fb95acf7c457672e70d0.js 916 bytes <{1}> <{2}> <{3}>
> ./g [4] ./index.js 7:0-13
[7] ./g.js 916 bytes {0} [built]
chunk {1} a65f8652fd07c12d0049.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
chunk {1} a1e683753eca705a0882.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
> ./index main
[3] ./e.js 899 bytes {1} [built]
[4] ./index.js 111 bytes {1} [built]
[6] ./f.js 900 bytes {1} [built]
chunk {2} 4c485a9e1dc58eedfbd1.js 1.76 KiB ={1}= ={3}= >{0}< [initial] [rendered] [recorded] aggressive splitted
chunk {2} d43339a3d0f86c6b8d90.js 1.76 KiB ={1}= ={3}= >{0}< [initial] [rendered] [recorded] aggressive splitted
> ./index main
[0] ./b.js 899 bytes {2} [built]
[5] ./a.js 899 bytes {2} [built]
chunk {3} 337c857e3e34cc5ef72d.js 1.76 KiB ={1}= ={2}= >{0}< [initial] [rendered] [recorded] aggressive splitted
chunk {3} 6c7fb52c5514dbfbf094.js 1.76 KiB ={1}= ={2}= >{0}< [initial] [rendered] [recorded] aggressive splitted
> ./index main
[1] ./c.js 899 bytes {3} [built]
[2] ./d.js 899 bytes {3} [built]
Child content-change:
Hash: 1d3bfcee111df03fa625
Hash: a82dbd8d6c7a22df1caf
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
706f97eb6a2b8fb1a17e.js 1.05 KiB 0 [emitted]
a65f8652fd07c12d0049.js 9.92 KiB 1 [emitted]
4c485a9e1dc58eedfbd1.js 1.94 KiB 2 [emitted]
337c857e3e34cc5ef72d.js 1.94 KiB 3 [emitted]
Entrypoint main = 4c485a9e1dc58eedfbd1.js 337c857e3e34cc5ef72d.js a65f8652fd07c12d0049.js
chunk {0} 706f97eb6a2b8fb1a17e.js 916 bytes <{1}> <{2}> <{3}>
fb95acf7c457672e70d0.js 1.05 KiB 0 [emitted]
a1e683753eca705a0882.js 9.92 KiB 1 [emitted]
d43339a3d0f86c6b8d90.js 1.94 KiB 2 [emitted]
6c7fb52c5514dbfbf094.js 1.94 KiB 3 [emitted]
Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js
chunk {0} fb95acf7c457672e70d0.js 916 bytes <{1}> <{2}> <{3}>
> ./g [4] ./index.js 7:0-13
[7] ./g.js 916 bytes {0} [built]
chunk {1} a65f8652fd07c12d0049.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
chunk {1} a1e683753eca705a0882.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
> ./index main
[3] ./e.js 899 bytes {1} [built]
[4] ./index.js 111 bytes {1} [built]
[6] ./f.js 900 bytes {1} [built]
chunk {2} 4c485a9e1dc58eedfbd1.js 1.76 KiB ={1}= ={3}= >{0}< [initial] [rendered] [recorded] aggressive splitted
chunk {2} d43339a3d0f86c6b8d90.js 1.76 KiB ={1}= ={3}= >{0}< [initial] [rendered] [recorded] aggressive splitted
> ./index main
[0] ./b.js 899 bytes {2} [built]
[5] ./a.js 899 bytes {2} [built]
chunk {3} 337c857e3e34cc5ef72d.js 1.76 KiB ={1}= ={2}= >{0}< [initial] [rendered] [recorded] aggressive splitted
chunk {3} 6c7fb52c5514dbfbf094.js 1.76 KiB ={1}= ={2}= >{0}< [initial] [rendered] [recorded] aggressive splitted
> ./index main
[1] ./c.js 899 bytes {3} [built]
[2] ./d.js 899 bytes {3} [built]
64 changes: 34 additions & 30 deletions test/statsCases/aggressive-splitting-on-demand/expected.txt
@@ -1,61 +1,65 @@
Hash: af168fd06ab994207f62
Hash: ca712e9bc95207b9082e
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
031881c6ced2f576ff79.js 1.94 KiB 5 [emitted]
ba1a8dd27d611254d495.js 1.93 KiB 0 [emitted]
81950df8ced1664c8037.js 1.96 KiB 2 [emitted]
2a7cf3b38962fac54bb9.js 1.94 KiB 3 [emitted]
acfde31fdfbd1bdb41c4.js 1.01 KiB 4 [emitted]
f4818881f9e5138ad8ac.js 1 KiB 1 [emitted]
93666bd6f2b79d06cb66.js 1.94 KiB 6, 7 [emitted]
a28f1d7d7367daaaf00a.js 1 KiB 7 [emitted]
1c507089c2c8ceb9757d.js 1.94 KiB 8 [emitted]
9ac0014114101e5f7d2c.js 1.94 KiB 9, 1 [emitted]
f507739d37522e79688a.js 8.38 KiB 10 [emitted] main
Entrypoint main = f507739d37522e79688a.js
chunk {0} ba1a8dd27d611254d495.js 1.76 KiB <{10}> ={1}= ={2}= ={3}= ={7}= ={9}= [recorded] aggressive splitted
620d3f8d9bdb989cde07.js 1.94 KiB 6, 7 [emitted]
4467a9f70ef8365bcb32.js 1.93 KiB 0 [emitted]
8debdc7e72b763a13e35.js 1.96 KiB 2 [emitted]
6a2c2702ac98f9f90db9.js 1.94 KiB 3, 1 [emitted]
258ba4b441feff644266.js 1.01 KiB 4 [emitted]
8ae4998ca98adb2a08ea.js 1.94 KiB 5 [emitted]
aafb9d82e452def4c3bb.js 1 KiB 1 [emitted]
344e13508b62e833aacf.js 1 KiB 7 [emitted]
2aaed192bbfbc2302c53.js 1.94 KiB 8 [emitted]
72e04d4eaed46d9aac4c.js 1.94 KiB 9 [emitted]
d20b83dfd7d0fd0c8793.js 8.41 KiB 10 [emitted] main
1165c0cca1ba14a506ff.js 1.94 KiB 11 [emitted]
Entrypoint main = d20b83dfd7d0fd0c8793.js
chunk {0} 4467a9f70ef8365bcb32.js 1.76 KiB <{10}> ={1}= ={2}= ={3}= ={7}= ={9}= [recorded] aggressive splitted
> ./b ./d ./e ./f ./g [11] ./index.js 5:0-44
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
[0] ./b.js 899 bytes {0} {5} [built]
[1] ./d.js 899 bytes {0} {8} [built]
chunk {1} f4818881f9e5138ad8ac.js 899 bytes <{10}> ={0}= ={2}= ={8}=
chunk {1} aafb9d82e452def4c3bb.js 899 bytes <{10}> ={0}= ={2}= ={8}=
> ./c ./d ./e [11] ./index.js 3:0-30
> ./b ./d ./e ./f ./g [11] ./index.js 5:0-44
[2] ./e.js 899 bytes {1} {9} [built]
chunk {2} 81950df8ced1664c8037.js 1.76 KiB <{10}> ={0}= ={1}= ={3}= ={6}= ={7}= ={9}= [recorded] aggressive splitted
[2] ./e.js 899 bytes {1} {3} [built]
chunk {2} 8debdc7e72b763a13e35.js 1.76 KiB <{10}> ={0}= ={1}= ={11}= ={3}= ={6}= ={7}= ={9}= [recorded] aggressive splitted
> ./f ./g ./h ./i ./j ./k [11] ./index.js 4:0-51
> ./b ./d ./e ./f ./g [11] ./index.js 5:0-44
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
[3] ./f.js 899 bytes {2} [built]
[4] ./g.js 901 bytes {2} [built]
chunk {3} 2a7cf3b38962fac54bb9.js 1.76 KiB <{10}> ={0}= ={2}= ={6}= ={7}= ={9}= [recorded] aggressive splitted
> ./f ./g ./h ./i ./j ./k [11] ./index.js 4:0-51
chunk {3} 6a2c2702ac98f9f90db9.js 1.76 KiB <{10}> ={0}= ={2}= ={7}= ={9}= [rendered] [recorded] aggressive splitted
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
[6] ./h.js 899 bytes {3} [built]
[7] ./i.js 899 bytes {3} [built]
chunk {4} acfde31fdfbd1bdb41c4.js 899 bytes <{10}>
[2] ./e.js 899 bytes {1} {3} [built]
[6] ./h.js 899 bytes {3} {11} [built]
chunk {4} 258ba4b441feff644266.js 899 bytes <{10}>
> ./a [11] ./index.js 1:0-16
[10] ./a.js 899 bytes {4} [built]
chunk {5} 031881c6ced2f576ff79.js 1.76 KiB <{10}>
chunk {5} 8ae4998ca98adb2a08ea.js 1.76 KiB <{10}>
> ./b ./c [11] ./index.js 2:0-23
[0] ./b.js 899 bytes {0} {5} [built]
[5] ./c.js 899 bytes {5} {8} [built]
chunk {6} 93666bd6f2b79d06cb66.js 1.76 KiB <{10}> ={2}= ={3}=
chunk {6} 620d3f8d9bdb989cde07.js 1.76 KiB <{10}> ={11}= ={2}=
> ./f ./g ./h ./i ./j ./k [11] ./index.js 4:0-51
[8] ./j.js 901 bytes {6} {9} [built]
[9] ./k.js 899 bytes {6} {7} [built]
chunk {7} a28f1d7d7367daaaf00a.js 899 bytes <{10}> ={0}= ={2}= ={3}= ={9}=
chunk {7} 344e13508b62e833aacf.js 899 bytes <{10}> ={0}= ={2}= ={3}= ={9}=
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
[9] ./k.js 899 bytes {6} {7} [built]
chunk {8} 1c507089c2c8ceb9757d.js 1.76 KiB <{10}> ={1}= [recorded] aggressive splitted
chunk {8} 2aaed192bbfbc2302c53.js 1.76 KiB <{10}> ={1}= [recorded] aggressive splitted
> ./c ./d ./e [11] ./index.js 3:0-30
[1] ./d.js 899 bytes {0} {8} [built]
[5] ./c.js 899 bytes {5} {8} [built]
chunk {9} 9ac0014114101e5f7d2c.js 1.76 KiB <{10}> ={0}= ={2}= ={3}= ={7}= [recorded] aggressive splitted
chunk {9} 72e04d4eaed46d9aac4c.js 1.76 KiB <{10}> ={0}= ={2}= ={3}= ={7}= [rendered] [recorded] aggressive splitted
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
[2] ./e.js 899 bytes {1} {9} [built]
[7] ./i.js 899 bytes {9} {11} [built]
[8] ./j.js 901 bytes {6} {9} [built]
chunk {10} f507739d37522e79688a.js (main) 248 bytes >{0}< >{1}< >{2}< >{3}< >{4}< >{5}< >{6}< >{7}< >{8}< >{9}< [entry]
chunk {10} d20b83dfd7d0fd0c8793.js (main) 248 bytes >{0}< >{1}< >{11}< >{2}< >{3}< >{4}< >{5}< >{6}< >{7}< >{8}< >{9}< [entry] [rendered]
> ./index main
[11] ./index.js 248 bytes {10} [built]
[11] ./index.js 248 bytes {10} [built]
chunk {11} 1165c0cca1ba14a506ff.js 1.76 KiB <{10}> ={2}= ={6}= [rendered] [recorded] aggressive splitted
> ./f ./g ./h ./i ./j ./k [11] ./index.js 4:0-51
[6] ./h.js 899 bytes {3} {11} [built]
[7] ./i.js 899 bytes {9} {11} [built]
2 changes: 1 addition & 1 deletion test/statsCases/chunks-development/expected.txt
@@ -1,4 +1,4 @@
Hash: 5ce1f032cffdff8368b5
Hash: e81afb52ad447e8765ab
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
Expand Down
2 changes: 1 addition & 1 deletion test/statsCases/chunks/expected.txt
@@ -1,4 +1,4 @@
Hash: 7870601bc1a1a4f9c4c1
Hash: 4a1bda30edd6ae541ab2
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
Expand Down
2 changes: 1 addition & 1 deletion test/statsCases/color-disabled/expected.txt
@@ -1,4 +1,4 @@
Hash: 5ebdffcace96139575ac
Hash: 0b32ee714cee3c8b25d4
Time: Xms
Built at: Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT
Asset Size Chunks Chunk Names
Expand Down
2 changes: 1 addition & 1 deletion test/statsCases/color-enabled-custom/expected.txt
@@ -1,4 +1,4 @@
Hash: <CLR=BOLD>5ebdffcace96139575ac</CLR>
Hash: <CLR=BOLD>0b32ee714cee3c8b25d4</CLR>
Time: <CLR=BOLD>X</CLR>ms
Built at: Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=39,BOLD><CLR=22><CLR=BOLD>Chunk Names</CLR>
Expand Down
2 changes: 1 addition & 1 deletion test/statsCases/color-enabled/expected.txt
@@ -1,4 +1,4 @@
Hash: <CLR=BOLD>5ebdffcace96139575ac</CLR>
Hash: <CLR=BOLD>0b32ee714cee3c8b25d4</CLR>
Time: <CLR=BOLD>X</CLR>ms
Built at: Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=39,BOLD><CLR=22><CLR=BOLD>Chunk Names</CLR>
Expand Down
2 changes: 1 addition & 1 deletion test/statsCases/commons-chunk-min-size-0/expected.txt
@@ -1,4 +1,4 @@
Hash: 2a374ac6d98475951384
Hash: cad25b99a073374722a7
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
Expand Down
@@ -1,4 +1,4 @@
Hash: d86d9e4d7a615c762442
Hash: c176225f44e51c7a39a4
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
Expand Down
14 changes: 7 additions & 7 deletions test/statsCases/commons-plugin-issue-4980/expected.txt
@@ -1,25 +1,25 @@
Hash: cdd753ac70c5ff3b74bedd7e476c27a1777b4d27
Hash: 1c62a4c91035f66150df2425703c4fe7d61799b3
Child
Hash: cdd753ac70c5ff3b74be
Hash: 1c62a4c91035f66150df
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
app.js 5.58 KiB 0 [emitted] app
vendor.a86979cc789cd5f9d78f.js 619 bytes 1 [emitted] vendor
Entrypoint app = vendor.a86979cc789cd5f9d78f.js app.js
vendor.c0e73bece4137a7015c2.js 619 bytes 1 [emitted] vendor
Entrypoint app = vendor.c0e73bece4137a7015c2.js app.js
[./constants.js] 87 bytes {1} [built]
[./entry-1.js] ./entry-1.js + 2 modules 190 bytes {0} [built]
| ./entry-1.js 67 bytes [built]
| ./submodule-a.js 59 bytes [built]
| ./submodule-b.js 59 bytes [built]
Child
Hash: dd7e476c27a1777b4d27
Hash: 2425703c4fe7d61799b3
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
app.js 5.6 KiB 0 [emitted] app
vendor.a86979cc789cd5f9d78f.js 619 bytes 1 [emitted] vendor
Entrypoint app = vendor.a86979cc789cd5f9d78f.js app.js
vendor.c0e73bece4137a7015c2.js 619 bytes 1 [emitted] vendor
Entrypoint app = vendor.c0e73bece4137a7015c2.js app.js
[./constants.js] 87 bytes {1} [built]
[./entry-2.js] ./entry-2.js + 2 modules 197 bytes {0} [built]
| ./entry-2.js 67 bytes [built]
Expand Down
6 changes: 3 additions & 3 deletions test/statsCases/define-plugin/expected.txt
@@ -1,14 +1,14 @@
Hash: 40b9288c7b06181fe56c92fc98986ee18223c384
Hash: 189d0d15eb46be80d1f9eaead63561588b554cc6
Child
Hash: 40b9288c7b06181fe56c
Hash: 189d0d15eb46be80d1f9
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
main.js 2.63 KiB 0 [emitted] main
Entrypoint main = main.js
[0] ./index.js 24 bytes {0} [built]
Child
Hash: 92fc98986ee18223c384
Hash: eaead63561588b554cc6
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
Expand Down
2 changes: 1 addition & 1 deletion test/statsCases/exclude-with-loader/expected.txt
@@ -1,4 +1,4 @@
Hash: 8ba560cc1610e1d6a812
Hash: 8b3d74c47fe62d34ee43
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
Expand Down
2 changes: 1 addition & 1 deletion test/statsCases/external/expected.txt
@@ -1,4 +1,4 @@
Hash: bceb26d8b2be7c67df1d
Hash: 3386bd94ba1fc3ae7f29
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
Expand Down

0 comments on commit 6e175bc

Please sign in to comment.