Sha1 password hash linux

What I want is to get the sha1 hash value of a specific password.

So, for example, if my password was “hi”, what command would I need to type in linux to get the hashed hello value?

I tried

echo -n "hello" | sha1sum 

but the return value did not give the value that was accepted in the database stored procedure, which takes a hashed value to verify the input (that the problem is not in this stored procedure, because we use it everywhere for verbal purposes).

Basically,

I just need to know the command to give the string and return its hashed value

Thanks!:)

+4
source share
3 answers

The format of the password may vary in different applications. For example, for /etc/passwd you can generate the SHA-256 password with:

 # perl -e 'print crypt("password", q($5$salt$)), "\n";' $5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1 # 

For passwords in LDAP (for example, for slapd.conf ) it can be:

 # slappasswd -h "{SSHA}" New password: Re-enter new password: {SSHA}bjEe8dPBjyecc7hD1kUhxQUdF9dt4Hya # 

You need to know the exact password format for your application and how to generate passwords.

+5
source

I know this is really old, but here's why it didn't work and what to do about it:

At startup

 echo -n "hello" | sha1sum 

as in your example, you get

 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d - 

Note the "-" at the end.

The hash in front is the correct hash of the hash to greet, but the trait will interfere with the hash.

To get only the first part, you can do this:

 echo -n "hello" | sha1sum | awk '{print $1}' 

This will pass your output through awk and give you only the 1st column. Result: correct sha1 for "hello"

 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 

Hope this helps someone.

+5
source
 echo -n YOUR_TEXT | sha1sum | awk '{print $1}' 

exchange YOUR_TEXT with the text you want to delete it.

+1
source

All Articles