Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENCRYPT mysql and crypt php #6

Open
kzpm opened this issue Jan 12, 2019 · 1 comment
Open

ENCRYPT mysql and crypt php #6

kzpm opened this issue Jan 12, 2019 · 1 comment

Comments

@kzpm
Copy link

kzpm commented Jan 12, 2019

After installing the plugin with all correct credentials for accessing database and tables, changing the password fails with the notice "INFO[DATA]: Something went wrong. Either current password is incorrect, or new password does not match criteria."

Echoing the sql statement seems a little problematic with PDO mysql, so I cannot exactly observe how the plugin is 'talking' to mysql.

My mailserver stores passwords in the mysql users table as ENCRYPT($password, CONCAT('$6$', SUBSTRING(SHA(RAND()), -16).

The plugin, however, uses crypt() and mb_strlen to compare hashes of stored passwords.
I think ENCRYPT() and the way hashes are compared in the plugin do not match ..

Maybe the ENCRYPT() function for mysql is not the right way to store password, in the context of this plugin.

One way to overcome the problem is to alter code in the plugin so it matches my criteria, however I think it is better to alter the layout of the mysql password storage.

Does anyone have suggestions for storing passwords, so it meets the conventions in the plugin?

@daufinsyd
Copy link

hello kzpm

not sure if it'll help but the 3rd example of the crypt doc from php (http://php.net/manual/en/function.crypt.php) helped me uderstanding how it works.

I just made a postgresql version and I think your problem you be on line 191:
':crypt' => crypt($sNewPassword, '$'.md5(rand()))

Try to change "$" to the corresponding hash algo (eg "$6$"). At least it worked for me.
Btw mayby yout password is catched by the regex ? !preg_match('/[^A-Za-z0-9]+/'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants