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
25 changes: 25 additions & 0 deletions app/prework.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const crypto = require('crypto');

const text = 'Hello World!';
const hash = crypto.createHmac('sha256', text).digest('hex');
console.log(hash);

function encodeText(text, password, algorithm) {
const cipher = crypto.createCipher(algorithm, password);

let encrypted = cipher.update(text, 'utf8', 'hex');
encrypted += cipher.final('hex');
return encrypted;
}

console.log(encodeText('Hello, World!', 'M0j3 has|0!', 'aes-256-cbc'));

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

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

console.log(decodeText('352c9abb9cd20b41766f352b2611bb7b', 'M0j3 has|0!','aes-256-cbc'));
12 changes: 11 additions & 1 deletion app/zadanie01.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e';

//Twój kod
const crypto =require('crypto');

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

for(let i=0;i<array.length; i++) {
let a =crypto.createHmac('rmd160', array[i]).digest('hex');
if(MY_PWD_HASH===a){
console.log(array[i]);
}
console.log(a);
}
15 changes: 14 additions & 1 deletion app/zadanieDnia1.js
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
//Twój kod
//Twój kod
const fs = require('fs');
const crypto = require('crypto');

process.argv.forEach((val, index) => {
if(index > 1 ){
fs.readFile(val, 'utf-8', (err, data)=> {
if(err === null) {
let hash = crypto.createHmac('sha256', data).digest('hex');
console.log(hash);
}
});
}
});
12 changes: 11 additions & 1 deletion app/zadanieDnia2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const ENCRYPTED_TEXT = '4f9fa8f98650091c4910f5b597773c0a48278cfb001fe4eb3ff47ada85cbf0ed3dc17016b031e1459e6e4d9b001ab6e102c11e834a98dce9530c9668c47b76ee6f09d075d19a38e48b415e067c6ddcfad0d3526c405a4f4f2fb1e7502f303c40';

//Twój kod
const crypto = require('crypto');
//Twój kod
function decodeText(encodedText, password, algorithm) {
const decipher = crypto.createDecipher(algorithm, password);

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

console.log(decodeText(ENCRYPTED_TEXT, 'PysęjkkyDw','aes-256-ecb'));