diff --git a/vs/node/README.md b/vs/node/README.md new file mode 100644 index 00000000..e04b4053 --- /dev/null +++ b/vs/node/README.md @@ -0,0 +1,35 @@ +### References + +- [Reddit - Node 17 currently breaks most Webpack](https://www.reddit.com/r/webdev/comments/qd14bm/node_17_currently_breaks_most_webpack/) +- [Webpack Hashed Module IDs Plugin](https://webpack.js.org/plugins/hashed-module-ids-plugin/) +- [Angular CLI GitHub Issue #1656](https://github.com/angular/angular-cli/issues/1656) +- [Stack Overflow - Error Message: error:0308010C:digital envelope routines:unsupported](https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported) +- [Node.js Blog - OpenSSL November 2022 Vulnerability](https://nodejs.org/en/blog/vulnerability/openssl-november-2022) +- [Node.js GitHub Pull Request #40478](https://github.com/nodejs/node/pull/40478) +- [Node.js GitHub Issue #40455](https://github.com/nodejs/node/issues/40455) +- [Webpack.js.org config](https://github.com/webpack/webpack.js.org/commit/5a81c718d470cd4e82f177a5bd099164f4c6f7e9#diff-154021c8c1ce914c5be753b5667e4e615d0edfcb0874240c4fbf72a6424c7e65) + + +### Webpack + + +`webpack.config.js` +```javascript + +module.exports = { + output: { + //https://webpack.js.org/configuration/output/#outputhashdigest + hashFunction: 'sha256' + }, +}; +``` +OR xxhash64 as default by: + +`webpack.config.js` +```javascript +module.exports = { + experiments: { + futureDefaults: true, + }, +}; +``` \ No newline at end of file diff --git a/vs/node/hash.js b/vs/node/hash.js new file mode 100644 index 00000000..0ef14f06 --- /dev/null +++ b/vs/node/hash.js @@ -0,0 +1,15 @@ +const crypto = require('crypto'); + +function generateHash(data, algo) { + const hash = crypto.createHash(algo); + hash.update(data); + const hashedData = hash.digest('hex'); + + return hashedData; +} + +const testData = 'Hello, World!'; +const hashedData = generateHash(testData, "md4");//"md5", "sha256", "sha512" ... are fine. + +console.log('Original Data:', testData); +console.log('Hash:', hashedData); diff --git a/vs/node/n16_fine.sh b/vs/node/n16_fine.sh new file mode 100755 index 00000000..109c5d11 --- /dev/null +++ b/vs/node/n16_fine.sh @@ -0,0 +1,7 @@ +NODE_VERSION=v16.20.2 + +source /Users/hoaphan/.nvm/nvm.sh +nvm install $NODE_VERSION +nvm use $NODE_VERSION + +node hash.js \ No newline at end of file diff --git a/vs/node/n17_broken.sh b/vs/node/n17_broken.sh new file mode 100755 index 00000000..f8f5fb73 --- /dev/null +++ b/vs/node/n17_broken.sh @@ -0,0 +1,7 @@ +NODE_VERSION=v17.0.0 + +source /Users/hoaphan/.nvm/nvm.sh +nvm install $NODE_VERSION +nvm use $NODE_VERSION + +node hash.js \ No newline at end of file diff --git a/vs/node/n17_unadvisible.sh b/vs/node/n17_unadvisible.sh new file mode 100755 index 00000000..f288e614 --- /dev/null +++ b/vs/node/n17_unadvisible.sh @@ -0,0 +1,7 @@ +NODE_VERSION=v17.0.0 + +source /Users/hoaphan/.nvm/nvm.sh +nvm install $NODE_VERSION +nvm use $NODE_VERSION + +node --openssl-legacy-provider hash.js \ No newline at end of file