Sinisterly
Password Hasher - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Python (https://sinister.li/Forum-Python)
+--- Thread: Password Hasher (/Thread-Password-Hasher)



Password Hasher - BlueCat - 06-22-2014

Hello Guys, Today I bringing you my Password Hasher, A rather easy script!

[Image: b85f4f1b278a71e0ef6542dc144a0640.png]

Code:
import uuid import hashlib def hash_password(password): # uuid is used to generate a random number salt = uuid.uuid4().hex return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt new_pass = input('Please enter a password: ') hashed_password = hash_password(new_pass) print('Hashed password: ' + hashed_password)

was going to make it allow it to verify it but meh.

Updated again


RE: Password Hasher - BlueCat - 06-22-2014

ignore the post above me, I submitted it before finishing it. So, Yes, To this I have updated it to where you can Find the hash out of files. By doing this you just change the name of the file. for example, In the code look where it says.

Code:
with open('hchasher.py', 'rb') as afile:

change it to whatever you want. Though it's only working for small files as of now.


Full code.
Code:
import uuid import hashlib def hash_password(password): salt = uuid.uuid4().hex return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt new_pass = input('Please enter a password: ') hashed_password = hash_password(new_pass) print('Hashed password: ' + hashed_password) #This is a different file, This will hash files #Join Hack Community hasher = hashlib.md5() with open('hchasher.py', 'rb') as afile: buf = afile.read() hasher.update(buf) print(hasher.hexdigest())



RE: Password Hasher - Anima Templi - 06-22-2014

Why not make it take command line arguments for the path to the file? It's something I think every Python programmer should have at least a brief understanding of.

Second, instead of using string concatenation, try to use string formatting.

Code:
print('Hashed password: ' %s) % hashed_password



RE: Password Hasher - Ex094 - 06-23-2014

How do you even work with that Reddish eye blasting Console :S My eyes hurt lol...

Also use sys.argv to get command line input just as Anima said


RE: Password Hasher - Deque - 06-23-2014

Added the "Source"-tag.
And command line arguments is a good suggestion. It makes your program more flexible to use.


RE: Password Hasher - BlueCat - 06-23-2014

(06-23-2014, 07:15 AM)Ex094 Wrote: How do you even work with that Reddish eye blasting Console :S My eyes hurt lol...

Also use sys.argv to get command line input just as Anima said

Lol, It's easy to work with. Confusedmile:

And all of you, Thanks for your comments, I will work on it. Confusedmile: