Manual talk:$wgPasswordSalt

Jump to navigation Jump to search

Creating the Hash[edit]

I rm all the sample code because it's just plain wrong. Blatantly, it does not generate the stuff demanded at Manual:User_table#user_password.

I have succeeded in doing what's required but I'm very weak in PHP and I don't cotton to cramming that much tricky stuff into a SQL query. So I did it in Perl. This is for $wgPasswordSalt=true (default).

use Digest::MD5 'md5_hex';
my $salt    = sprintf "%08x", ( int( rand() * 2**31 ) );
my $hashed  = md5_hex( $password );
   $hashed  = md5_hex( $salt . q{-} . $hashed );
   $hashed  = q{:B:} . $salt . q(:) . $hashed  ;

Xiong 10:15, 26 December 2013 (UTC)