Generating hashed passwords from commandline
ruby -r ‘digest/sha1′ -e ‘puts Digest::SHA1.hexdigest("password")’
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
meaning of "it"
ruby -r ‘digest/sha1′ -e ‘puts Digest::SHA1.hexdigest("password")’
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
There’s always…
echo -n “password” | sha1sum
(provided you have sha1sum installed, had to install from macports here)
Ray Krueger
21 Jul 09 at 7:47 pm
Both commands work on my ubuntu, however output is different. Both can’t be correct. right? Yours is surely short and sweet. I needed to remember it for when I need to create a user/login in mysql database manually. Hence the blog
Sharad
23 Jul 09 at 1:07 am
Be sure to pass the -n to echo. Otherwise Echo will append a newline to the string and cause the hash to be different. I Spent 10 minutes trying to figure that out till I finally looked at the man page for echo. I assumed that echo took no arguments, turns out it has one, -n!
The downside of using sha1sum or md5sum is that the output is based on it creating an index of hash to filename. So the output always has a trailing “-” on it. If you’re scripting the Ruby way is cleaner. If you just need to hash some string quick you can just ignore the “-”.
Ray Krueger
23 Jul 09 at 2:48 pm