From 7ef4e6d814d8df0a168060c12f26b66a2b5c7a5a Mon Sep 17 00:00:00 2001 From: Mikhail Pakhomov Date: Mon, 9 Mar 2020 15:36:00 +0300 Subject: [PATCH 01/38] Add library for aes --- package-lock.json | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/package-lock.json b/package-lock.json index c0ac6a6..c0f1c40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5296,6 +5296,11 @@ } } }, + "aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" + }, "aggregate-error": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", diff --git a/package.json b/package.json index 212d617..f63f940 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@types/react-dom": "^16.9.5", "@types/react-redux": "^7.1.7", "@types/react-router-dom": "^5.1.3", + "aes-js": "^3.1.2", "crc": "^3.8.0", "fletcher": "0.0.3", "node-sass": "^4.13.1", From b5e8dea136fc6e40c8accca8e08035315b3fe3c4 Mon Sep 17 00:00:00 2001 From: Mikhail Pakhomov Date: Mon, 9 Mar 2020 15:41:19 +0300 Subject: [PATCH 02/38] Add library for SHA --- package-lock.json | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/package-lock.json b/package-lock.json index c0f1c40..9881af8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7643,6 +7643,11 @@ "randomfill": "^1.0.3" } }, + "crypto-js": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.0.0.tgz", + "integrity": "sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==" + }, "css": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", diff --git a/package.json b/package.json index f63f940..df3df81 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@types/react-router-dom": "^5.1.3", "aes-js": "^3.1.2", "crc": "^3.8.0", + "crypto-js": "^4.0.0", "fletcher": "0.0.3", "node-sass": "^4.13.1", "react": "^16.12.0", From d6f835eb84697e1f33800c65cecf93a64339ea9f Mon Sep 17 00:00:00 2001 From: Mikhail Pakhomov Date: Thu, 12 Mar 2020 15:43:34 +0300 Subject: [PATCH 03/38] Start hashing and aes --- src/App.tsx | 2 + src/config.ts | 2 +- src/containers/Checksum/Checksum.tsx | 5 +- src/containers/Hashing/Hashing.tsx | 88 ++++++++++++++++++++++++++ src/containers/Hashing/index.ts | 1 + src/containers/Home/Home.tsx | 2 +- src/libmethods/checksum/crc16/index.ts | 10 +-- src/libmethods/checksum/index.ts | 1 + src/libmethods/hashing/index.ts | 25 ++++++++ src/libmethods/hashing/sha256/index.ts | 7 ++ src/libmethods/index.ts | 12 ++++ src/react-app-env.d.ts | 4 ++ 12 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 src/containers/Hashing/Hashing.tsx create mode 100644 src/containers/Hashing/index.ts create mode 100644 src/libmethods/hashing/index.ts create mode 100644 src/libmethods/hashing/sha256/index.ts diff --git a/src/App.tsx b/src/App.tsx index 53d32a3..a7036b3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,6 +9,7 @@ import { Home } from 'containers/Home'; import { Encrypt } from 'containers/Encrypt'; import { Decrypt } from 'containers/Decrypt'; import { Checksum } from 'containers/Checksum'; +import { Hashing } from 'containers/Hashing'; import { NotFound } from 'containers/NotFound'; const App = () => { @@ -21,6 +22,7 @@ const App = () => { + diff --git a/src/config.ts b/src/config.ts index 481fd3e..b9c9c5b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,5 +6,5 @@ export const links = [ { title: 'Зашифровать', href: '/encrypt/', isActive: true }, { title: 'Расшифровать', href: '/decrypt/', isActive: true }, { title: 'Посчитать контрольную сумму', href: '/checksum/', isActive: true }, - { title: 'Хешировать', href: '/hash/', isActive: false }, + { title: 'Хешировать', href: '/hash/', isActive: true }, ]; diff --git a/src/containers/Checksum/Checksum.tsx b/src/containers/Checksum/Checksum.tsx index 009b356..2a2e83b 100644 --- a/src/containers/Checksum/Checksum.tsx +++ b/src/containers/Checksum/Checksum.tsx @@ -66,7 +66,10 @@ export default function() { {checksum.map((item, index) => ( - {item.name} + + {item.name} + {'version' in item ? '/' + item.version : ''} + {item.value} ))} diff --git a/src/containers/Hashing/Hashing.tsx b/src/containers/Hashing/Hashing.tsx new file mode 100644 index 0000000..e7df25b --- /dev/null +++ b/src/containers/Hashing/Hashing.tsx @@ -0,0 +1,88 @@ +import * as React from 'react'; + +import { ContentBox } from 'components/ContentBox'; +import { Alarm } from 'components/Alarm'; + +import { hashingMethods } from 'libmethods'; +import { calculateHash } from 'libmethods/hashing'; + +export default function() { + const [method, setMethod] = React.useState(hashingMethods[0]); + const [text, setText] = React.useState(''); + const [error, setError] = React.useState(''); + const [hash, setHash] = React.useState([]); + + const onSubmit = (event: any) => { + event.preventDefault(); + setError(''); + + if (text === '') { + setError('Введите текст от которого необходимо посчитать хеш!'); + return; + } + + setHash(calculateHash(method, text)); + }; + + return ( + <> + + 1) Выберите метод для подсчета хеша: + + {/* 2) Введите текст для которого требуется найти контрольную сумму: +