use strict;

return sub
{
	my $dbh = shift;
	

	{
		my $sth = $dbh->prepare("select id,passwd from jin_user where passwd_md5=''");
		$sth->execute;
	
		my $sth1 = $dbh->prepare("update jin_user set passwd_md5=md5(?) where id=?");
	
		while (my $row = $sth->fetchrow_hashref)
		{
			my $passwd_packed = $row->{passwd};
			
			my $len = substr($passwd_packed, 0, 2) + 0;
			my $passwd = pack("H*", substr($passwd_packed, 2, $len * 2));
			
			$sth1->execute($passwd, $row->{id});
		}
	}

	return;
};
