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.
[tags]md5, pearl, hash, passwords, hashing, scripting[/tags]
Here is my version of the same thing . . .
I always seem to have openssl, but not always Digest::MD5.
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
echo -n test | md5sum
You can do it without openssl.
#!/bin/sh
echo -n $* | md5sum
You can do it without openssl & dont forget to use ‘-n’ with echo.
#!/bin/sh
echo -n $* | md5sum