Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rozwiązania #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
12 changes: 11 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const crypto = require('crypto');
const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e';

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

passwords.forEach(pswd => {
algorythms.forEach(algorythm => {
const result = crypto.createHmac(algorythm, pswd);
console.log(result.digest('hex') === MY_PWD_HASH ? '-> ' : ' ', algorythm, `"${pswd}"`);
});
});
20 changes: 19 additions & 1 deletion app/zadanieDnia1.js
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
//Twój kod
//Twój kod
const fs = require('fs');
const crypto = require('crypto');

const file = process.argv[2] || './data/zadanieDia1/testFile.txt';

const controlSum = (file) => {
console.log('file: ', file);
fs.readFile(file, 'utf8', (err, data) => {
console.log('data: ', data);
if (!err) {
console.log('hash: ', crypto.createHmac('sha256', data).digest('hex'));
} else {
console.log('Błąd przy czytaniu pliku:\n', err);
}
});
};

controlSum(file); //czemu rezultat jest inny niż w poleceniu?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git zmienia znaki końca linii w plikach tekstowych między różnymi systemami

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

//Twój kod
//Twój kod
const password = 'PysęjkkyDw';
const algorythms = ['aes192', 'aes-256-cbc', 'aes-256-ecb'];

algorythms.forEach(algorythm => {
const decipher = crypto.createDecipher(algorythm, password);
let decrypted = decipher.update(ENCRYPTED_TEXT, 'hex', 'utf8');
try {
decrypted += decipher.final('utf8');
console.log(decrypted);
}
catch (err) {
console.log(algorythm, 'nop');
}
});