SA-MP Forums Archive
How to Change to Sha1 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to Change to Sha1 (/showthread.php?tid=625630)



How to Change to Sha1 - DandyCorleone - 04.01.2017

hi friends.. i need help with pcp website in login.php, this pcp use WP_Hash whirlpool, but my gamemodes use sha1.
i want change this login.php to sha1 password, i already change it, but dont work.. can help?



PHP код:

<?php
    session_start
();
    include 
"koneksi.php";
    if(isset(
$_SESSION['playername']))
    {
        
go('index.php''You already logged in.');
    }
    if(!isset(
$_POST['username'], $_POST['password']))
    {
        
go('index.php''Please fillout all required forms.');
    }
    else
    {
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?");
        
$query->execute(array($_POST['username'], strtoupper(hash("whirlpool"$_POST['password']))));
        if(
$query->rowCount() > 0)
        {
            
$data $query->fetch();
            
go('index.php''Succesfully logged in.');
            
$_SESSION['playername'] = $data['name'];
            
$_SESSION['playerlevel'] = $data['level'];
        }
        else
        {
            
go('index.php''Wrong username or password.');
        }
    }



Re: How to Change to Sha1 - Yaa - 04.01.2017

http://php.net/manual/en/function.sha1.php

here you go
PHP код:
<?php 
    session_start
(); 
    include 
"koneksi.php"
    if(isset(
$_SESSION['playername'])) 
    { 
        
go('index.php''You already logged in.'); 
    } 
    if(!isset(
$_POST['username'], $_POST['password'])) 
    { 
        
go('index.php''Please fillout all required forms.'); 
    } 
    else 
    { 
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?"); 
        
$query->execute(array($_POST['username'], strtoupper(sha1($_POST['password']))); 
        if(
$query->rowCount() > 0
        { 
            
$data $query->fetch(); 
            
go('index.php''Succesfully logged in.'); 
            
$_SESSION['playername'] = $data['name']; 
            
$_SESSION['playerlevel'] = $data['level']; 
        } 
        else 
        { 
            
go('index.php''Wrong username or password.'); 
        } 
    }
        else 
        { 
            
go('index.php''Wrong username or password.'); 
        } 
    }



Re: How to Change to Sha1 - DandyCorleone - 04.01.2017

ahh nice... thanks


Re: How to Change to Sha1 - DandyCorleone - 04.01.2017

bro.. i have erors

Parse error: parse error in C:\xampp\htdocs\cnr\check.php on line 15

PHP код:
$query->execute(array($_POST['username'], strtoupper(sha1($_POST['password']))); 



Re: How to Change to Sha1 - BiosMarcel - 04.01.2017

You might have a problem when users try to login, since their old password is still whirlpool hashed, you have to force all users to set a new password. Also, why did u switch to sha1 instead of SHA256?


Re: How to Change to Sha1 - Yaa - 04.01.2017

try now

PHP код:
<?php  
    session_start
();  
    include 
"koneksi.php";  
    if(isset(
$_SESSION['playername']))  
    {  
        
go('index.php''You already logged in.');  
    }  
    if(!isset(
$_POST['username'], $_POST['password']))  
    {  
        
go('index.php''Please fillout all required forms.');  
    }  
    else  
    {  
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?");  
        
$query->execute(array($_POST['username'], sha1($_POST['password'])));  
        if(
$query->rowCount() > 0)  
        {  
            
$data $query->fetch();  
            
go('index.php''Succesfully logged in.');  
            
$_SESSION['playername'] = $data['name'];  
            
$_SESSION['playerlevel'] = $data['level'];  
        }  
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    } 
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    }



Re: How to Change to Sha1 - DandyCorleone - 04.01.2017

Quote:
Originally Posted by Yaa
Посмотреть сообщение
try now

PHP код:
<?php  
    session_start
();  
    include 
"koneksi.php";  
    if(isset(
$_SESSION['playername']))  
    {  
        
go('index.php''You already logged in.');  
    }  
    if(!isset(
$_POST['username'], $_POST['password']))  
    {  
        
go('index.php''Please fillout all required forms.');  
    }  
    else  
    {  
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?");  
        
$query->execute(array($_POST['username'], sha1($_POST['password'])));  
        if(
$query->rowCount() > 0)  
        {  
            
$data $query->fetch();  
            
go('index.php''Succesfully logged in.');  
            
$_SESSION['playername'] = $data['name'];  
            
$_SESSION['playerlevel'] = $data['level'];  
        }  
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    } 
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    }
worked!! tahanks man
+1rep