apache - How to programmaticaly build an APR1-MD5 using PHP -


A lot I want to generate an htpasswd file entry from PHP. However, it needs APR 1 (Apache) style, as outlined in the original answer (no answer was shown how to apply the APR1 style), to work with mod_dav_svn

I do not think so

  function crypt_apr1_md5 ($ plainpasswd) {$ salt = substr (str_shuffle)  

I have come to know that an implementation Implementation ("Abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8); $ Len = strlen ($ plainpasswd); $ Text = $ plainpasswd '$ Apr1 $' $ Salt; $ Bin = pack ("H32", md5 ($ plainpasswd. $ Salt. $ Plainpasswd)); ($ I = $ len; $ i> $; - $ i - = 16) {$ text. = Substr ($ bin, 0, min (16, $ i)); } ($ I = $ len; $ i> 0; $ i & gt; & gt; = 1) {$ text. = ($ I and 1)? Chr (0): $ plainpasswd {0}; } $ Bin = pack ("H32", MD5 ($ text)); {$ New = ($ i & amp; 1) for ($ I = 0; $ i & lt; 1000; $ i ++)? $ Plain password: $ bin; If $ ($ i% 3) $ new = $ Salt; If $ ($ i% 7) $ new = $ Plainpasswd; $ New = ($ I & amp; 1)? $ Bin: $ plainpasswd; $ Bin = pack ("H32", MD5 ($ new)); } ($ I = 0; $ i & lt; 5; $ i ++) {$ k = $ i + 6; $ J = $ i + 12; If ($ j ==16) $ j = 5; $ Tmp = $ bin [$ i] $ Bin [$ k] $ Bin [$ j]. $ Tmp; } $ Tmp = chr (0) .cr (0). $ Bin [11] $ Tmp; $ Tmp = strtr (strrev (substr (base64_encode ($ tmp), 2)), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 +/", "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); Return "$". "Apr1". "$" $ Salt "$" $ Tmp; }

But it does not generate a working password. I think it might be something with Apache version but I'm not sure. (I am running on CNTOS5)

It is revealed that I made a mistake and it Functions are actually the work of APR 1 HTPDD entry they look different from Apache but they work.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -