Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sha1 password hash linux

What i want is to be able to get the sha1 hashed value of a particular password.

So for instance if my password was "hello" what command would i need to type into linux to get the sha1 hashed value of hello?

I tried

echo -n "hello" | sha1sum

but the value it returned did not give a value that was accepted by the database stored procedure that takes in the hashed value to verify a login(which the issue is not in this stored procedure because we use it all over the place for verfication purposes).

BASICALLY,

i just need to know a command to give a string and get back the sha1 hashed value of it

Thanks! :)

like image 252
Dan Avatar asked Mar 25 '13 22:03

Dan


People also ask

What is Linux password hash?

Whether we are talking about a web application or an operating system, they should always be in hash form (on Linux, for example, hashed passwords are stored in the /etc/shadow file). Hashing is the process through which, by the use of some complex algorithms, a password is turned into a different string.

What is Shasum hash?

sha1sum is a computer program that calculates and verifies SHA-1 hashes. It is commonly used to verify the integrity of files. It (or a variant) is installed by default on most Linux distributions.

What is SHA-1 command?

What is the sha1sum command in UNIX? The sha1sum command computes the SHA-1 message digest of a file. This allows it be compared to a published message digest to check whether the file is unmodified from the original. As such the sha1sum command can be used to attempt to verify the integrity of a file.


1 Answers

I know this is really old but here is why it did not work and what to do about it:

When you run the

echo -n "hello" | sha1sum

as in your example you get

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d  -

Notice the '-' in the end.

The hash in front is the correct sha1 hash for hello, but the dash messes up the hash.

In order to get only the first part you can do this:

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

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

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

Hope this helps someone.

like image 177
Dom Avatar answered Oct 08 '22 00:10

Dom