Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
const crypto = require('crypto');

const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e';

//Twój kod
const tabPasswd = [
'??TegoHasła',
'CodersLab',
'Node.js Szyfruje Pliki',
'Zaźółć Gęślą Jaźń',
'Moje Haslo 1@3!',
'111#$((@)n',
'Dzisiaj Szyfruje 83'
];

const tabAlgorithms = ['sha256', 'sha512', 'md5', 'rmd160'];

const searchPasswd = (tabPasswd, tabAlgorithms, hash) => {
let searchPasswd;

tabPasswd.forEach(p => {
tabAlgorithms.forEach(a => {
if (crypto.createHmac(a, p).digest('hex') === hash) {
searchPasswd = `Szukane hasło to: ${p}. Uzyto algorytmu: ${a}`;
};
});
});

return searchPasswd ? console.log(searchPasswd) : console.log('Hasło nie zostało odnalezione');
}

searchPasswd(tabPasswd, tabAlgorithms, MY_PWD_HASH);
14 changes: 13 additions & 1 deletion app/zadanieDnia1.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
//Twój kod
const fs = require('fs');
const crypto = require('crypto');

const path = process.argv.slice(2).toString();

const checksum = path => {
fs.readFile(path, 'utf-8', (err, data) => {
if (err) return console.log('Błąd odczytu pliku');
console.log(crypto.createHmac('sha256', data).digest('hex'));
});
};

checksum(path)
18 changes: 17 additions & 1 deletion app/zadanieDnia2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
const crypto = require('crypto');

const ENCRYPTED_TEXT = '4f9fa8f98650091c4910f5b597773c0a48278cfb001fe4eb3ff47ada85cbf0ed3dc17016b031e1459e6e4d9b001ab6e102c11e834a98dce9530c9668c47b76ee6f09d075d19a38e48b415e067c6ddcfad0d3526c405a4f4f2fb1e7502f303c40';

//Twój kod
const tabAlgorithms = ['aes192', 'aes-256-ecb', 'aes-256-cbc', ];

const decodeText = (encodedText, password, tabAlgorithms) => {
tabAlgorithms.forEach(x => {
const decipher = crypto.createDecipher(x, password);
decrypted = decipher.update(encodedText, 'hex', 'utf8');
try {
console.log(`Prawidłowy algorytm: ${x}\n${decrypted += decipher.final('utf8')}`);
} catch(err) {
console.log(`Nieprawidłowy algorytm: ${x}`)
}
})
};

decodeText(ENCRYPTED_TEXT, 'PysęjkkyDw', tabAlgorithms);