A few days ago i showed you a script in which using Bash y md5sum I encrypted the password correct of a simple security system that I programmed myself.
In other words, in a terminal it said:
echo "desdelinux" | md5sum
And I would get the MD5 sum of that word or text, in this case: from linux
Thanks to hackan i met shasum ... which is more secure than md5sum.
Explaining a little more, MD5 is a way to protect text, following the previous example, the MD5 of from linux is
The detail is that no matter how long the text is, its MD5 will always be 33 characters (letters and numbers), for example this is the MD5 of: Learn to be better from Linux
As you can see, 33 characters equal.
The problem this has is that for security purposes MD5 is not the most recommended, for example to encrypt passwords, since MD5 hash collisions have already been detected. In other words, a hash collision is that two different text strings can give the same output, that is, that (for example) "linux" and "hsjajeya" both give the same hash sum.
For those like me who are a bit paranoid about security, there are other alternatives ... today I will talk about SHA.
To my way of seeing, SHA (Secure Hash Algorithm, Invented by NSA) serves the same purpose as MD5, only it gives us more options.
For example, a hash sum SHA of "from linux" would:
echo "desdelinux" | shasum
And the result is:
As you can see, it is more characters than an MD5, now it is 41 characters instead of the 33 of the MD5.
But this is not all, this sum is using SHA-1, but we can significantly improve security using sha256sum , sha384sum y sha512sum.
What I would do is simple, add an encryption of more bits 😉 ...
See here the hash of «from linux" but with sha256sum:
echo "desdelinux" | sha256sum
As you can see, many more characters, specifically 65.
I personally use sha512sum in my script to protect the password hehe ... and to continue with the example, the sha512sum of "from linux" would:
They are exactly: 129 characters 😉…. this, I want to see who would be the smartass that could guess… LOL!
How to know the MD5 or SHA of the content of a file?
Suppose we have the file from linux.txt ... which contains the following:
<° Linux (aka DesdeLinux) is a site dedicated to topics related to Software and Free Technologies. Our goal is none other than to provide all those users who are new to the world of GNU / Linux, a place where they can acquire new knowledge in the easiest way possible.
To know the MD5 sum of this file we put in a terminal:
This will show us:
To do it with SHA instead of MD5… guess 😀…:
And it will show us:
Or if you like, you can use sha256sum, sha384sum or sha512sum 😉
Anyway, the article ends here.
I have found it extremely interesting to learn about this, I have always been attracted to things related to security, I hope you also find it interesting.
If anyone has any questions, well I do not consider myself by far an expert on the subject, but without a doubt I will try to help you 😀