0

I am having trouble to transfer email user account which is saved in MySQL to another server. Here is the detail:

I have an old email server which using MySQL to store user account information. The password field uses MySQL ENCRYPT function to save the users password. So if I want change the user's password I can do:

 UPDATE  `mail`.`users` SET  `password` = ENCRYPT(  '12345' ) WHERE CONVERT(  `users`.`email` USING utf8 ) =  'g@veecall.com' LIMIT 1 ;

Then the new password "12345" saved in the table as string of " 2I6JOeg.JukJ."

Now I build a new server using iRedMail. When I try to transfer user account I have trouble to transfer the password field. Because the iRadMail/dovecot is using MD5-CRAM to encrypt the password then save it in the MySQL. All the password string is started with "$1$".

So, is there a way to make the MySQL encrypted password string "2I6JOeg.JukJ." convert to MD5 hash "$1$................."?

Thanks for help.

Gao
  • 1
  • 1
  • 1

1 Answers1

1

Firstly MD5 is a hashing algorithm not a encryption algorithm. The main reason for this is that it is virtually impossible to calculate the original password from the hash value generated by MD5. MD5 creates a hash value and it basically a trap door function in other words it is a one way function.

Encryption will allow you to encrypt and decrypt IF you knew the key. Big difference. Hope you understand that.

Now for your problem.

Unless you have the original password before it was encrypted there is no reasonable way besides brute force to create the MD5 equivalent of the password. The encrypted passwords hash and the unecrypted/plain text password hash will be two different think.

If you can decrypt all the passwords you currently have to their plain text form you can perform the MD5 hashing on the plain text values. If you cannot get the original plain text then you are out of luck.

Namphibian
  • 12,046
  • 7
  • 46
  • 76