diff --git a/app/zadanie01.js b/app/zadanie01.js index 842f75e..33f7082 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'); +var algs = ['sha256', 'sha512', 'md5', 'rmd160']; + +var pwds = [ '??TegoHasła', 'CodersLab', 'Node.js Szyfruje Pliki' , 'Zaźółć Gęślą Jaźń' , 'Moje Haslo 1@3!' , '111#$((@)n', 'Dzisiaj Szyfruje 83' ]; + +algs.forEach(alg => { + pwds.forEach(pwd => { + var hash= crypto.createHmac(alg, pwd) + .digest('hex'); + + if (MY_PWD_HASH===hash) { + console.log('algorytm: '+ alg + ', hasło: ' + pwd); + } + + }) + +}); \ No newline at end of file diff --git a/app/zadanieDnia1.js b/app/zadanieDnia1.js index 8c20173..4264777 100644 --- a/app/zadanieDnia1.js +++ b/app/zadanieDnia1.js @@ -1 +1,25 @@ -//Twój kod \ No newline at end of file +//Twój kod +var path; +var count = 0; +const crypto = require('crypto'); +const fs=require('fs'); + +process.argv.forEach((val, index) => { + if (count ===2) { + path = val; + + } + count++; +}); + +fs.readFile(path , 'utf8', (err, data) => { + if (err === null){ + var hash= crypto.createHmac('sha256', data) + .digest('hex'); + + console.log(hash); + + } else { + console.log('Błąd podczas odczytu pliku!', err); + } +});