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
22 changes: 21 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e';

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

// console.log(MY_PWD_HASH.length)

passes.filter( (pass) => {
algorithmTypes.filter((algo) => {
const hash = crypto.createHmac(algo, pass).digest('hex')
MY_PWD_HASH === hash ? console.log(`algorytm to: ${algo},
hasło to: ${pass}`) : null
})
})
32 changes: 31 additions & 1 deletion app/zadanieDnia1.js
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
//Twój kod
//Twój kod
const fs = require('fs');
const crypto = require('crypto');

const arr = process.argv[2];
console.log('argument to: ',arr);
// var text = '';
fs.readFile(arr, 'utf8', (err, data) => {
if (err === null) {
console.log('Poprawnie odczytano plik :', data);
// const paresData = JSON.parse(data);

console.log('type to: ' ,typeof data)

const text = data;

// console.log('type is: ', typeof paresData)
const hash = crypto.createHmac('sha256', text)
.digest('hex');
console.log('PASS IS: ', hash);






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

38 changes: 37 additions & 1 deletion app/zadanieDnia2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
const ENCRYPTED_TEXT = '4f9fa8f98650091c4910f5b597773c0a48278cfb001fe4eb3ff47ada85cbf0ed3dc17016b031e1459e6e4d9b001ab6e102c11e834a98dce9530c9668c47b76ee6f09d075d19a38e48b415e067c6ddcfad0d3526c405a4f4f2fb1e7502f303c40';

//Twój kod
//Twój kod

// console.log(ENCRYPTED_TEXT.length)


const text = 'Pobawmy się jak komputerowy Detektyw'
const result = []
text.split(" ").forEach( el => result.push(el[0] + el[el.length-1]) )
const pass = result.join('')

// console.log(pass)
// console.log('result: ',typeof result)

// decipher:

const crypto = require('crypto');
const algorithms = ['aes192', 'aes-256-cbc', 'aes-256-ecb'];



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

let decrypted = decipher.update(encodedText, 'hex', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
}


algorithms.forEach(el => {
try{
console.log(decodeText(ENCRYPTED_TEXT, pass, el))
}
catch(err){
// console.log('blad: ')
}
})