I was looking for an 'algo' to prepare the encrypted password of the shadow file of a Linux box. I need to prepare 600 hundred accounts and the local authentication is fast and reliable.
Get ready, because if you want to understand the base of this 'algo', you will have to find out in standards of cryptography mainly MD5.
So I got the code from others and translated:
# 0423.2000 by michal wallace http://www.sabren.com/
# based on perl's Crypt::PasswdMD5 by Luis Munoz (firstname.lastname@example.org)
# based on /usr/src/libcrypt/crypt.c from FreeBSD 2.2.5-RELEASE
# MANY THANKS TO
# Carey Evans - http://home.clear.net.nz/pages/c.evans/
# Dennis Marti - http://users.starpower.net/marti1/
You do it like this ...
$ppr = Authen::Passphrase::MD5Crypt->new(
salt => "Vd3f8aG6",
hash_base64 => "GcsdF4YCXb0PM2UmXjIoI1");
... but no translators from this code to C# or VB.
Using the Code
It's easy, think in a mixing key (salt or pepper) and crypt will mix it with the password.
public static String crypt(String password, String salt)
MD5Crypt.crypt("cat","hat") = $1$hat$aIZAkAKuZS4bQQyEO56ER/
- 5th October, 2007: Initial post