From c4140da86bcb4c79381f46035cda7c572e485e4e Mon Sep 17 00:00:00 2001 From: Greg Herbowicz Date: Wed, 31 Jan 2018 12:14:39 +0100 Subject: [PATCH 1/4] nothing found --- app/zadanie01.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/zadanie01.js b/app/zadanie01.js index 842f75e..980e4ce 100644 --- a/app/zadanie01.js +++ b/app/zadanie01.js @@ -1,3 +1,19 @@ const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e'; -//Twój kod \ No newline at end of file +const crypto = require('crypto'); + +const algorithm = ['aes192', 'aes-256-cbc', 'aes-256-ecb']; +const password = ['??TegoHasła', 'CodersLab', 'Node.js Szyfruje Pliki', 'Zaźółć Gęślą Jaźń', 'Moje Haslo 1@3!', '111#$((@)n', 'Dzisiaj Szyfruje 83']; + +password.forEach(pass => { + algorithm.forEach(alg => { + const decipher = crypto.createDecipher(alg, pass); + let decrypted = decipher.update(MY_PWD_HASH, 'hex', 'utf8'); + try { + decrypted += decipher.final('utf8'); + console.log(decrypted); + } catch (err) { + console.log('złe hasło'); + } + }); +}); From cb1210aa3d7ced0ebfaf925b616a0d1511ce9b4d Mon Sep 17 00:00:00 2001 From: Greg Herbowicz Date: Wed, 31 Jan 2018 12:27:58 +0100 Subject: [PATCH 2/4] ok --- app/zadanie01.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/zadanie01.js b/app/zadanie01.js index 980e4ce..11f3769 100644 --- a/app/zadanie01.js +++ b/app/zadanie01.js @@ -1,19 +1,13 @@ -const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e'; - const crypto = require('crypto'); +const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e'; -const algorithm = ['aes192', 'aes-256-cbc', 'aes-256-ecb']; const password = ['??TegoHasła', 'CodersLab', 'Node.js Szyfruje Pliki', 'Zaźółć Gęślą Jaźń', 'Moje Haslo 1@3!', '111#$((@)n', 'Dzisiaj Szyfruje 83']; +const algorithm = ['sha256', 'sha512', 'md5', 'rmd160']; password.forEach(pass => { algorithm.forEach(alg => { - const decipher = crypto.createDecipher(alg, pass); - let decrypted = decipher.update(MY_PWD_HASH, 'hex', 'utf8'); - try { - decrypted += decipher.final('utf8'); - console.log(decrypted); - } catch (err) { - console.log('złe hasło'); - } + const hash = crypto.createHmac(alg, pass) + .digest('hex'); + hash === MY_PWD_HASH && console.log('hasło: ', pass, 'algorytm: ', alg); }); }); From c6d0735a862c8f33293577ce3b951bf4170a8866 Mon Sep 17 00:00:00 2001 From: Greg Herbowicz Date: Wed, 31 Jan 2018 12:45:51 +0100 Subject: [PATCH 3/4] Update zadanieDnia1.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wychoddzi inny 'sha256' niż jest w treści zad.: 3843d52c1d256ddd5137d7665d743ab153fe39067572564a41659c388548d794 zamiast 4f7ae6569b55cb6275423ca1cdf31475e607da1d5204c110a58fb480c96e6eca --- app/zadanieDnia1.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/zadanieDnia1.js b/app/zadanieDnia1.js index 8c20173..5dfea44 100644 --- a/app/zadanieDnia1.js +++ b/app/zadanieDnia1.js @@ -1 +1,12 @@ -//Twój kod \ No newline at end of file +const fs = require('fs'); +const crypto = require('crypto'); + +fs.readFile(process.argv[2], 'utf8', (err, data) => { + if (err === null) { + const hash = crypto.createHmac('sha256', data) + .digest('hex'); + console.log(hash); + } else { + console.log('Błąd podczas odczytu pliku!', err); + } +}); From b02348c24e1445c6017f3f17025392dfd6e13ee9 Mon Sep 17 00:00:00 2001 From: Greg Herbowicz Date: Wed, 31 Jan 2018 13:15:47 +0100 Subject: [PATCH 4/4] Update zadanieDnia2.js --- app/zadanieDnia2.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/zadanieDnia2.js b/app/zadanieDnia2.js index 85846f4..edc24cd 100644 --- a/app/zadanieDnia2.js +++ b/app/zadanieDnia2.js @@ -1,3 +1,22 @@ const ENCRYPTED_TEXT = '4f9fa8f98650091c4910f5b597773c0a48278cfb001fe4eb3ff47ada85cbf0ed3dc17016b031e1459e6e4d9b001ab6e102c11e834a98dce9530c9668c47b76ee6f09d075d19a38e48b415e067c6ddcfad0d3526c405a4f4f2fb1e7502f303c40'; -//Twój kod \ No newline at end of file +const crypto = require('crypto'); + +let pass = ''; +const text = "Pobawmy się jak komputerowy Detektyw".split(' ').forEach(word => { + pass += word[0] + word[word.length - 1]; +}); +console.log(pass); + +const algorithm = ['aes192', 'aes-256-cbc', 'aes-256-ecb']; + +algorithm.forEach(alg => { + const decipher = crypto.createDecipher(alg, pass); + let decrypted = decipher.update(ENCRYPTED_TEXT, 'hex', 'utf8'); + try { + decrypted += decipher.final('utf8'); + console.log(decrypted); + } catch (err) { + console.log('zły algorytm'); + } +});