At first, I suppose you know that following
PHP guide,
It is not recommended to use this function to secure passwords, due to the fast nature of this hashing algorithm. See the Password Hashing FAQ for details and best practices.
SHA1 stands not far away from
MD5 in this case :)
Anyway,
the proper solution below (I've tested on my local environment):
1. Change the length of the
user_password field in the $Tu table (
minibbtable_users by default) - here you are right:
alter table minibbtable_users modify user_password varchar(40) not null default '';
2.
bb_cookie.php - change default function to this (
for an existing forum):
function writeUserPwd($pwd){
if(isset($_POST['mode']) and $_POST['mode']=='login' and strlen($GLOBALS['userpassword'])==32) {
$method='md5';
}
else $method='sha1';
return call_user_func($method, $pwd);
}
For a new forum, it's enough just to have:
function writeUserPwd($pwd){
return sha1($pwd);
}
3.
On an existing forum, force your users to change/update passwords if they are still in MD5
(don't apply this for a new forum) - we could not change MD5 to SH1 straight, so it's really required that all of your users change or update the passwords manually:
/* Changing to SH1 */
if($user_id>1){
$cookie=explode('|', $_COOKIE[$cookiename]);
if(strlen($cookie[1])==32 and $action!='prefs' and $action!='editprefs') {
header("{$rheader}{$main_url}/{$indexphp}action=prefs");
exit;
}
if($action=='prefs' and strlen($cookie[1])==32){
$warning='<span class="warning">Because of security updates, we require to change or update your password now. If you wouldn\'t like to change the password, just repeat the older password below.</span>';
}
}
/* --Changing to SH1 */
4. OPTIONAL - if you are on a secured hosting and do not mind to keep the Admin's password in a clear form, change nothing. If you'd like to keep the Admin's password encoded in SHA1, do as mentioned
in p.#3 of tom322's post above.
These steps could be useful also if you change to another encoding algorithm - except it would be much more difficult to plug it into existing forum, if the final encoding result is not equal to some defined length. For a new forum, another algorithm is more easier to plug-in at the initial forum running stage.
P.S. Always
avoid any JavaScript "solutions", as more as possible :)