Get a md5 of a string on a command line

One of the web applications I maintain stores md5 hashes in the database, instead of the actual passwords. This is a good practice - passwords are not stored in plain text, and knowing the has still does not give you a direct access to the system.

I whipped up this tiny shell script in order to easily get md5 hashes of strings on the command line (for example in case I need to go in and change some password directly in the database).

#!/usr/bin/perl
use Digest::MD5 qw(md5 md5_hex md5_base64);
print(md5_hex($ARGV[0]) . "\n")

This script takes a parameter string and prints out the md5 hash of that string to the standard output stream.

Related Posts:

  • Harnessing the Power of Million Monkeys
  • Posting Twitter Updates using Java
  • Lisp: Parse and Aggregate a CSV File
  • Command Line SCP for Windows
  • What is the point of explicit typing again?
  • Utilities
  • Strange Password Restrictions
  • Windows Administration Commands
  • Tweaking Firefox User-Agent Value
  • Adding new column to a text file

  • 2 Responses to “Get a md5 of a string on a command line”

    1. Gravatar Craig Betts UNITED STATES Says: Reply to this comment

      Here is my version of the same thing . . .

      #!/bin/sh

      echo $* | openssl dgst -md5

      I always seem to have openssl, but not always Digest::MD5.

      Posted using Mozilla Firefox Mozilla Firefox 2.0.0.1 on Solaris Solaris
    2. Gravatar Luke UNITED STATES Says: Reply to this comment

      Heh - I didn’t even think of that. I like yours better than mine now!

      I think what we have here is programmer vs. admin way of thinking.

      Programmer automatically goes “hey, I bet there is a [some-language] module/library for that somewhere…” when admin goes “I bet there is a tool for that somewhere…” P

      Posted using Mozilla Firefox Mozilla Firefox 2.0 on Ubuntu Linux Ubuntu Linux

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <pre lang=""> <em> <i> <strike> <strong>

    [Quote selected]