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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
*.*~
node_modules
12 changes: 12 additions & 0 deletions .idea/Node.js_challenge_dzien_3.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

193 changes: 193 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
const crypto = require('crypto');

const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e';

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

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

let whichPassword = (password, algorithms, hash) => {
let correctPassword;

password.forEach(p => {
algorithms.forEach(a => {
if (crypto.createHmac(a, p).digest('hex') === hash) {
correctPassword = `Our password is: ${p}. Our algorithm is: ${a}`;
};
});
});

return whichPassword ? console.log(correctPassword) : console.log('Password not find');
};

whichPassword(password, algorithms, MY_PWD_HASH);
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
const fs = require('fs');
const crypto = require('crypto');

function ReadAndCrypto(fileName) {
fs.readFile(fileName, 'utf8', (err, data) => {
if (err === null){
console.log("Poprawnie odczytano plik. \n");
const hash = crypto.createHmac('sha256', data)
.digest('hex');
console.log(hash);


} else {
console.log('Błąd podczas odczytu pliku!', err);
}
});
}

ReadAndCrypto(process.argv[2]);
18 changes: 17 additions & 1 deletion app/zadanieDnia2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
const ENCRYPTED_TEXT = '4f9fa8f98650091c4910f5b597773c0a48278cfb001fe4eb3ff47ada85cbf0ed3dc17016b031e1459e6e4d9b001ab6e102c11e834a98dce9530c9668c47b76ee6f09d075d19a38e48b415e067c6ddcfad0d3526c405a4f4f2fb1e7502f303c40';
const algorithms = ['aes192', 'aes-256-cbc', 'aes-256-ecb'];
const password = 'PysęjkkyDw';
const crypto = require('crypto');

function decodeText(text, password, algorithm){
const decipher = crypto.createDecipher(algorithm, password);

let decrypted = decipher.update(text, 'hex', 'utf8');
decrypted += decipher.final('utf8');

console.log(decrypted);
return decrypted;
}

decodeText(ENCRYPTED_TEXT, password, 'aes-256-ecb');



//Twój kod