Skip to content

Commit a4ed734

Browse files
committed
* Removed unsupported crypto hashes
1 parent f24e8b7 commit a4ed734

File tree

9 files changed

+7
-235
lines changed

9 files changed

+7
-235
lines changed

public/workers/FileWorker/index.html

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@
1010
const fs = window.require('fs');
1111
const crypto = window.require('crypto');
1212

13-
const fileHash = (filePath, md4, md5, sha1, sha224, sha256, sha3_224, sha3_256, sha3_384, sha3_512, sha384, sha512, ripemd160) => {
13+
const fileHash = (filePath, md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160) => {
1414
return new Promise((resolve, reject) => {
1515
let MD4,
1616
MD5,
1717
SHA1,
1818
SHA224,
1919
SHA256,
20-
SHA3_224,
21-
SHA3_256,
22-
SHA3_384,
23-
SHA3_512,
2420
SHA384,
2521
SHA512,
2622
RIPEMD160;
@@ -30,10 +26,6 @@
3026
if (sha1) SHA1 = crypto.createHash('sha1');
3127
if (sha224) SHA224 = crypto.createHash('sha224');
3228
if (sha256) SHA256 = crypto.createHash('sha256');
33-
if (sha3_224) SHA3_224 = crypto.createHash('sha3');
34-
if (sha3_256) SHA3_256 = crypto.createHash('sha3-256');
35-
if (sha3_384) SHA3_384 = crypto.createHash('sha3-384');
36-
if (sha3_512) SHA3_512 = crypto.createHash('sha3-512');
3729
if (sha384) SHA384 = crypto.createHash('sha384');
3830
if (sha512) SHA512 = crypto.createHash('sha512');
3931
if (ripemd160) RIPEMD160 = crypto.createHash('ripemd160');
@@ -47,10 +39,6 @@
4739
if (sha1) SHA1.update(data);
4840
if (sha224) SHA224.update(data);
4941
if (sha256) SHA256.update(data);
50-
if (sha3_224) SHA3_224.update(data);
51-
if (sha3_256) SHA3_256.update(data);
52-
if (sha3_384) SHA3_384.update(data);
53-
if (sha3_512) SHA3_512.update(data);
5442
if (sha384) SHA384.update(data);
5543
if (sha512) SHA512.update(data);
5644
if (ripemd160) RIPEMD160.update(data);
@@ -94,34 +82,6 @@
9482
.toString()
9583
});
9684
}
97-
if (sha3_224) {
98-
newHashes.push({
99-
type: 'SHA3-224',
100-
hash: SHA3_224.digest('hex')
101-
.toString()
102-
});
103-
}
104-
if (sha3_256) {
105-
newHashes.push({
106-
type: 'SHA3-256',
107-
hash: SHA3_256.digest('hex')
108-
.toString()
109-
});
110-
}
111-
if (sha3_384) {
112-
newHashes.push({
113-
type: 'SHA3-384',
114-
hash: SHA3_384.digest('hex')
115-
.toString()
116-
});
117-
}
118-
if (sha3_512) {
119-
newHashes.push({
120-
type: 'SHA3-512',
121-
hash: SHA3_512.digest('hex')
122-
.toString()
123-
});
124-
}
12585
if (sha384) {
12686
newHashes.push({
12787
type: 'SHA-384',
@@ -160,7 +120,7 @@
160120
}
161121

162122
ipcRenderer.on("calculate-file-hash", (e, data) => {
163-
fileHash(data.filePath, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha3_224, data.sha3_256, data.sha3_384, data.sha3_512, data.sha3, data.sha384, data.sha512, data.ripemd160)
123+
fileHash(data.filePath, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha384, data.sha512, data.ripemd160)
164124
.then(data => {
165125
ipcRenderer.send("file-hash-calculated", data);
166126
})

public/workers/TextWorker/index.html

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
const ipcRenderer = window.require('electron').ipcRenderer;
1010
const crypto = window.require('crypto');
1111

12-
const textHash = (text, md4, md5, sha1, sha224, sha256, sha3_224, sha3_256, sha3_384, sha3_512, sha384, sha512, ripemd160) => {
12+
const textHash = (text, md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160) => {
1313
return new Promise((resolve, reject) => {
1414
let newHashes = [];
1515
try {
@@ -58,43 +58,6 @@
5858
.toString()
5959
});
6060
}
61-
if (sha3_224) {
62-
newHashes.push({
63-
type: 'SHA3-224',
64-
hash: crypto.createHash('sha3-224')
65-
.update(text)
66-
.digest('hex')
67-
.toString()
68-
});
69-
}
70-
if (sha3_256) {
71-
newHashes.push({
72-
type: 'SHA3-256',
73-
hash: crypto.createHash('sha3-256')
74-
.update(text)
75-
.digest('hex')
76-
.toString()
77-
});
78-
}
79-
80-
if (sha3_384) {
81-
newHashes.push({
82-
type: 'SHA3-384',
83-
hash: crypto.createHash('sha3-384')
84-
.update(text)
85-
.digest('hex')
86-
.toString()
87-
});
88-
}
89-
if (sha3_512) {
90-
newHashes.push({
91-
type: 'SHA3-512',
92-
hash: crypto.createHash('sha3-512')
93-
.update(text)
94-
.digest('hex')
95-
.toString()
96-
});
97-
}
9861
if (sha384) {
9962
newHashes.push({
10063
type: 'SHA-384',
@@ -133,7 +96,7 @@
13396
};
13497

13598
ipcRenderer.on('calculate-text-hash', (e, data) => {
136-
textHash(data.text, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha3_224, data.sha3_256, data.sha3_384, data.sha3_512, data.sha3, data.sha384, data.sha512, data.ripemd160)
99+
textHash(data.text, data.md4, data.md5, data.sha1, data.sha224, data.sha256, data.sha384, data.sha512, data.ripemd160)
137100
.then(data => {
138101
ipcRenderer.send('text-hash-calculated', data);
139102
})

src/contexts/CryptoContextReducer/index.jsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ import CryptoReducer from '../../reducers/CryptoReducer';
44
const md4 = localStorage.md4 && localStorage.md4 === 'true' ? true : !localStorage.md4;
55
const md5 = localStorage.md5 && localStorage.md5 === 'true' ? true : !localStorage.md5;
66
const sha1 = localStorage.sha1 && localStorage.sha1 === 'true' ? true : !localStorage.sha1;
7-
// eslint-disable-next-line camelcase
8-
const sha3_224 = localStorage.sha3_224 && localStorage.sha3_224 === 'true' ? true : !localStorage.sha3_224;
9-
// eslint-disable-next-line camelcase
10-
const sha3_256 = localStorage.sha3_256 && localStorage.sha3_256 === 'true' ? true : !localStorage.sha3_256;
11-
// eslint-disable-next-line camelcase
12-
const sha3_384 = localStorage.sha3_384 && localStorage.sha3_384 === 'true' ? true : !localStorage.sha3_384;
13-
// eslint-disable-next-line camelcase
14-
const sha3_512 = localStorage.sha3_512 && localStorage.sha3_512 === 'true' ? true : !localStorage.sha3_512;
157
const sha224 = localStorage.sha224 && localStorage.sha224 === 'true' ? true : !localStorage.sha224;
168
const sha256 = localStorage.sha256 && localStorage.sha256 === 'true' ? true : !localStorage.sha256;
179
const sha384 = localStorage.sha384 && localStorage.sha384 === 'true' ? true : !localStorage.sha384;
@@ -24,10 +16,6 @@ const initState = {
2416
sha1,
2517
sha224,
2618
sha256,
27-
sha3_224,
28-
sha3_256,
29-
sha3_384,
30-
sha3_512,
3119
sha384,
3220
sha512,
3321
ripemd160,

src/reducers/CryptoReducer/Actions/actionTypes.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ export const SET_SHA384_STATE = 'SET_SHA384_STATE';
66
export const SET_SHA512_STATE = 'SET_SHA512_STATE';
77
export const SET_RIPEMD160_STATE = 'SET_RIPEMD160_STATE';
88
export const SET_SHA224_STATE = 'SET_SHA224_STATE';
9-
export const SET_SHA3_224_STATE = 'SET_SHA3_224_STATE';
10-
export const SET_SHA3_256_STATE = 'SET_SHA3_256_STATE';
11-
export const SET_SHA3_384_STATE = 'SET_SHA3_384_STATE';
12-
export const SET_SHA3_512_STATE = 'SET_SHA3_512_STATE';
139
export const RESET_CRYPTO_REDUCER = 'RESET_CRYPTO_REDUCER';
1410
export const SET_FILE_HASHES = 'SET_FILE_HASHES';
1511
export const SET_TEXT_HASHES = 'SET_TEXT_HASHES';

src/reducers/CryptoReducer/Actions/index.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import {
1313
SET_SHA224_STATE,
1414
SET_SHA256_STATE,
1515
SET_SHA384_STATE,
16-
SET_SHA3_224_STATE,
17-
SET_SHA3_256_STATE,
18-
SET_SHA3_384_STATE,
19-
SET_SHA3_512_STATE,
2016
SET_SHA512_STATE,
2117
SET_TEXT_COMPARE_HASH,
2218
SET_TEXT_COMPARING,
@@ -66,30 +62,6 @@ export const setSha224State = (state) => ({
6662
payload: state,
6763
});
6864

69-
// eslint-disable-next-line camelcase
70-
export const setSha3_224State = (state) => ({
71-
type: SET_SHA3_224_STATE,
72-
payload: state,
73-
});
74-
75-
// eslint-disable-next-line camelcase
76-
export const setSha3_256State = (state) => ({
77-
type: SET_SHA3_256_STATE,
78-
payload: state,
79-
});
80-
81-
// eslint-disable-next-line camelcase
82-
export const setSha3_384State = (state) => ({
83-
type: SET_SHA3_384_STATE,
84-
payload: state,
85-
});
86-
87-
// eslint-disable-next-line camelcase
88-
export const setSha3_512State = (state) => ({
89-
type: SET_SHA3_512_STATE,
90-
payload: state,
91-
});
92-
9365
export const resetCryptoReducer = () => ({
9466
type: RESET_CRYPTO_REDUCER,
9567
});

src/reducers/CryptoReducer/index.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import {
1313
SET_SHA224_STATE,
1414
SET_SHA256_STATE,
1515
SET_SHA384_STATE,
16-
SET_SHA3_224_STATE,
17-
SET_SHA3_256_STATE,
18-
SET_SHA3_384_STATE,
19-
SET_SHA3_512_STATE,
2016
SET_SHA512_STATE,
2117
SET_TEXT_COMPARE_HASH,
2218
SET_TEXT_COMPARING,
@@ -72,30 +68,6 @@ const CryptoReducer = (state, action) => {
7268
...state,
7369
ripemd160: action.payload,
7470
};
75-
case SET_SHA3_224_STATE:
76-
localStorage.sha3_224 = action.payload;
77-
return {
78-
...state,
79-
sha3_224: action.payload,
80-
};
81-
case SET_SHA3_256_STATE:
82-
localStorage.sha3_256 = action.payload;
83-
return {
84-
...state,
85-
sha3_256: action.payload,
86-
};
87-
case SET_SHA3_384_STATE:
88-
localStorage.sha3_384 = action.payload;
89-
return {
90-
...state,
91-
sha3_384: action.payload,
92-
};
93-
case SET_SHA3_512_STATE:
94-
localStorage.sha3_512 = action.payload;
95-
return {
96-
...state,
97-
sha3_512: action.payload,
98-
};
9971
case SET_SHA224_STATE:
10072
localStorage.sha224 = action.payload;
10173
return {
@@ -110,10 +82,6 @@ const CryptoReducer = (state, action) => {
11082
localStorage.sha384 = true;
11183
localStorage.sha512 = true;
11284
localStorage.ripemd160 = true;
113-
localStorage.sha3_224 = true;
114-
localStorage.sha3_256 = true;
115-
localStorage.sha3_384 = true;
116-
localStorage.sha3_512 = true;
11785
localStorage.sha224 = true;
11886

11987
return {
@@ -123,10 +91,6 @@ const CryptoReducer = (state, action) => {
12391
sha1: true,
12492
sha224: true,
12593
sha256: true,
126-
sha3_224: true,
127-
sha3_256: true,
128-
sha3_384: true,
129-
sha3_512: true,
13094
sha384: true,
13195
sha512: true,
13296
ripemd160: true,

src/routes/File/index.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ const File = () => {
5959
const file = crypto.currentFile;
6060

6161
const {
62-
// eslint-disable-next-line camelcase
63-
md4, md5, sha1, sha224, sha256, sha3_224, sha3_256,
64-
// eslint-disable-next-line camelcase
65-
sha3_384, sha3_512, sha384, sha512, ripemd160,
62+
md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160,
6663
} = crypto;
6764

6865
const compare = crypto.fileComparing;
@@ -146,10 +143,6 @@ const File = () => {
146143
sha1,
147144
sha224,
148145
sha256,
149-
sha3_224,
150-
sha3_256,
151-
sha3_384,
152-
sha3_512,
153146
sha384,
154147
sha512,
155148
ripemd160,

src/routes/Settings/index.jsx

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ import {
4545
setSha224State,
4646
setSha256State,
4747
setSha384State,
48-
// eslint-disable-next-line camelcase
49-
setSha3_224State, setSha3_256State, setSha3_384State, setSha3_512State,
5048
setSha512State,
5149
} from '../../reducers/CryptoReducer/Actions';
5250

@@ -91,10 +89,7 @@ const Settings = () => {
9189
const languageStatus = state.languageEnabled;
9290

9391
const {
94-
// eslint-disable-next-line camelcase
95-
md4, md5, sha1, sha224, sha256, sha3_224, sha3_256,
96-
// eslint-disable-next-line camelcase
97-
sha3_384, sha3_512, sha384, sha512, ripemd160,
92+
md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd160,
9893
} = crypto;
9994

10095
const [errorMessage, setErrorMessage] = useState(null);
@@ -352,58 +347,6 @@ const Settings = () => {
352347
label={language.sha256}
353348
/>
354349

355-
<FormControlLabel
356-
control={(
357-
<Checkbox
358-
/* eslint-disable-next-line camelcase */
359-
checked={sha3_224}
360-
onChange={(e) => d2(setSha3_224State(e.target.checked))}
361-
value="sha3_224"
362-
color="primary"
363-
/>
364-
)}
365-
label={language.sha3_224}
366-
/>
367-
368-
<FormControlLabel
369-
control={(
370-
<Checkbox
371-
/* eslint-disable-next-line camelcase */
372-
checked={sha3_256}
373-
onChange={(e) => d2(setSha3_256State(e.target.checked))}
374-
value="sha3_256"
375-
color="primary"
376-
/>
377-
)}
378-
label={language.sha3_256}
379-
/>
380-
381-
<FormControlLabel
382-
control={(
383-
<Checkbox
384-
/* eslint-disable-next-line camelcase */
385-
checked={sha3_384}
386-
onChange={(e) => d2(setSha3_384State(e.target.checked))}
387-
value="sha3_384"
388-
color="primary"
389-
/>
390-
)}
391-
label={language.sha3_384}
392-
/>
393-
394-
<FormControlLabel
395-
control={(
396-
<Checkbox
397-
/* eslint-disable-next-line camelcase */
398-
checked={sha3_512}
399-
onChange={(e) => d2(setSha3_512State(e.target.checked))}
400-
value="sha3_512"
401-
color="primary"
402-
/>
403-
)}
404-
label={language.sha3_512}
405-
/>
406-
407350
<FormControlLabel
408351
control={(
409352
<Checkbox

0 commit comments

Comments
 (0)