Tatva-Artha

meaning of "it"

Generating hashed passwords from commandline

with 3 comments

ruby -r ‘digest/sha1′ -e ‘puts Digest::SHA1.hexdigest("password")’

http://www.tatvartha.com/wp-content/plugins/sociofluid/images/digg_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/reddit_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/stumbleupon_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/delicious_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/google_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/twitter_16.png

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Written by Sharad

July 21st, 2009 at 6:58 pm

Posted in All

3 Responses to 'Generating hashed passwords from commandline'

Subscribe to comments with RSS or TrackBack to 'Generating hashed passwords from commandline'.

  1. 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

  2. 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

  3. 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

Leave a Reply