Archive

Archive for May 10th, 2009

MySQL ENCRYPT() == PHP crypt + salt

May 10th, 2009 sgardner 0 Comments
PHP
Image via Wikipedia

I was working on a web interface to ease the addition of users/domains, aliases and forwards to my Postfix-sasl-smtp_auth mysql setup. I knew that the passwords were using mysql’s encypt() function, and this was the only way I was able to get postfix to authenticate and play nice with encrypted passwords. On the PHP side I was using PDO and I was looking for a way to encrypt the passwords using php, that would still allow users to authenticate when sending mail.

$salt = substr($_POST['postfix_mailbox_password'], 0, 2);
$password = crypt($_POST['postfix_mailbox_password'], $salt);

After much trial and error I finally had a working solution, by taking the first two characters of the password and using them as the salt value, I could then use PHP’s crypt() with the salt value to encrypt the password.

Reblog this post [with Zemanta]
Join the forum discussion on this post - (1) Posts
Categories: Uncategorized Tags:

In The Twitterverse!

May 10th, 2009 sgardner 0 Comments

My daily Tweets!

18:55 NASCAR Sprint Cup driver Jeremy Mayfield suspended after failing drug test ( bit.ly/ZDxd4 ) (via @web9media) #

19:11 I’m really liking Jr’s new Dew Car #NASCAR #

20:03 @kjchipmunk Beer Check! #

Automatically shipped by LoudTwitter

Categories: Uncategorized Tags:

Powered by WP Robot