I'm working on a website that is trying to switch from Apache authentication to PHP authentication for username/password on login. The passwords are currently stored in a file and they are encrypted in Apache's own md5 format (for example, $apr1$z6hoasr5$0Kk7p/8Hfhy9nBxu/hFUj1
).
The passwords are not stored in the database.
Now, I'm writing a PHP login script. My question is, how do I check if the typed password is the same as the encrypted password in the file? I've found code for generating APR1-MD5 based on a plain text password, but that is NOT what I need since it generates codes different than the ones in the file.
Long story short, is there a way to identically check whether the typed password is indeed the one saved in the file?
I know Apache has open source code for generating these, but the code is in C which I know next to nothing about.
Surely there's a way to migrate from Apache authentication to PHP without changing every user's password?