-
Notifications
You must be signed in to change notification settings - Fork 227
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
FG_Day_3 #4
Open
filipgad
wants to merge
4
commits into
CodersLab:master
Choose a base branch
from
filipgad:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
FG_Day_3 #4
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
//Twój kod | ||
|
||
const crypto = require('crypto'); | ||
|
||
const MY_PWD_HASH = '5dca0fc4e306d92b2077ad85e7c4bd87a3e8648e'; | ||
const password = [ | ||
'??TegoHasła', | ||
'CodersLab', | ||
'Node.js Szyfruje Pliki', | ||
'Zaźółć Gęślą Jaźń', | ||
'Moje Haslo 1@3!', | ||
'111#$((@)n', | ||
'Dzisiaj Szyfruje 83' | ||
]; | ||
const algorithm = ['sha256', 'sha512', 'md5', 'rmd160']; | ||
|
||
password.forEach( passwordElem => { | ||
algorithm.forEach( algorithmElem => { | ||
const hash = crypto.createHmac(algorithmElem, passwordElem) | ||
.digest('hex'); | ||
hash === MY_PWD_HASH ? console.log(`password: ${passwordElem}; algorithm: ${algorithmElem}`) : null; | ||
}); | ||
}); | ||
|
||
//Twój kod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
//Twój kod | ||
//Twój kod | ||
|
||
const fs = require('fs'); | ||
const crypto = require('crypto'); | ||
|
||
const file = process.argv[2]; | ||
|
||
fs.readFile(file, 'utf8', (err, data) => { | ||
if (err === null){ | ||
const hash = crypto.createHmac('sha256', data) | ||
.digest('hex'); | ||
console.log(hash); // d5b1c451f5a44e4fcce7af164b6470f4ebd06b16c8b65adda696c6c7f328289b | ||
} else { | ||
console.log('Błąd podczas odczytu pliku!', err); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
//Twój kod | ||
|
||
const crypto = require('crypto'); | ||
const ENCRYPTED_TEXT = '4f9fa8f98650091c4910f5b597773c0a48278cfb001fe4eb3ff47ada85cbf0ed3dc17016b031e1459e6e4d9b001ab6e102c11e834a98dce9530c9668c47b76ee6f09d075d19a38e48b415e067c6ddcfad0d3526c405a4f4f2fb1e7502f303c40'; | ||
const algorithm = ['aes192', 'aes-256-cbc', 'aes-256-ecb']; | ||
const text = 'Pobawmy się jak komputerowy Detektyw'; | ||
let password = ''; | ||
|
||
text.split(' ').forEach( textElem => { | ||
password += textElem[0] + textElem[textElem.length-1]; | ||
}); | ||
|
||
algorithm.forEach( algorithmElem => { | ||
const decipher = crypto.createDecipher(algorithmElem, password); | ||
|
||
let decrypted = decipher.update(ENCRYPTED_TEXT, 'hex', 'utf8'); | ||
try { | ||
decrypted += decipher.final('utf8'); | ||
console.log(`Good hacking! Decrypted text: \n ${decrypted}`); | ||
} catch(err) { | ||
console.log("You are a weak hacker."); | ||
} | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bardzo elegancko! |
||
|
||
//Twój kod |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bardzo fajne rozwiązanie. Mała podpowiedź: nieco czytelniejszy były tu
if
.