Forum | MySQL ENCRYPT() == PHP crypt + salt

April 11th, 2009
You must be logged in to post Login Register

Search Forums:


 






MySQL ENCRYPT() == PHP crypt + salt
Read original blog post

No Status Selected
UserPost

11:06 am
May 10, 2009


admin

Admin

posts 33

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]

Read original blog post


About the Geek Outpost forum

Most Users Ever Online:

8


Currently Online:

2 Guests

Forum Stats:

Groups: 2

Forums: 3

Topics: 33

Posts: 33

Membership:

There is 1 Member

There have been 0 Guests

There is 1 Admin

There are 0 Moderators

Top Posters:

Administrators: admin (33 Posts)




Share and Enjoy:
  • Twitter
  • Digg
  • Facebook
  • MySpace
  • Google Bookmarks
  • email
  • del.icio.us
  • LinkedIn
  • StumbleUpon
  • Reddit
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • Twitthis

Powered by WP Robot