LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2016, 10:02 PM   #1
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 245

Rep: Reputation: 16
hashing sha512 password in Linux with python


I'm going through some python exercise, and according to the book using
Quote:
hashlib.sha512(password + salt).hexdigest()
you can create a password in the same format stored in shadow file; however, I enter my password, and use the same salt that shows my shadow file password, and the resulting hashing doesn't match. What I'm doing wrong? am I using the wrong salt? how does the system get the ascii for the salt? and does the salt goest in front or after when using hashlib.sha512(password + salt).hexdigest()
this is an example of the shadow file user password
Quote:
nagios:$6$P9zn0KwR$tgfvvFWJJ5FKmoXiP5rXWOjwoEBOEoAuBi3EphRbJqqjWYvhEM2wa67L9XgQ7W591FxUNklkDIQsk4kij uhE50:16632:0:99999:7:::
the salt is the field from the second $ to the next $. and the actual password is what follows. I used that hash when using hashlib.sha512(password + hash), but I get a different hash... thanks
 
Old 01-18-2016, 07:32 AM   #2
teapottwo
Member
 
Registered: Sep 2013
Posts: 52

Rep: Reputation: Disabled
I may be wrong but I believe its the number of iterations it performs to slow down the generation, a lot more than standard.
 
Old 01-18-2016, 01:25 PM   #3
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Try the following:
Code:
import crypt
print crypt.crypt("your_pw", "$6$P9zn0KwR")
From: https://docs.python.org/2/library/cr...t#module-crypt

Edit: A good discussion here - http://stackoverflow.com/q/21090312

Last edited by norobro; 01-18-2016 at 07:40 PM.
 
Old 01-21-2016, 11:32 PM   #4
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 245

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by norobro View Post
Try the following:
Code:
import crypt
print crypt.crypt("your_pw", "$6$P9zn0KwR")
From: https://docs.python.org/2/library/cr...t#module-crypt

Edit: A good discussion here - http://stackoverflow.com/q/21090312
Thanks!... helped a lot
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 5.5 Password Hashing not working sraidr69 Linux - Software 4 01-01-2016 03:59 PM
LXer: Password Hashing Best Practice LXer Syndicated Linux News 0 06-10-2015 10:12 AM
Hashing a Password using Makepasswd/MD5 metallica1973 Linux - General 4 04-02-2012 03:39 PM
linux password hashing indienick Programming 5 05-18-2006 02:12 PM
Command-line 'adduser': password not hashing Talesin Fedora 0 10-08-2004 08:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration