Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8174589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:29:56+00:00 2026-06-06T22:29:56+00:00

I am trying to secure a password with sha1 hashing to a saltMe() function

  • 0

I am trying to secure a password with sha1 hashing to a saltMe() function but the ectrypted password ends up the same no matter what I type in the password field.
This might lead to a security vulnerability I think.

This is my salt function

**************************************************
* sha1 salt string to make a more secure hash 
***************************************************/
function SaltMe() {
   //Secret keyword encrypted with sha1
   return "4cefe49883b6dd1a00565e2a80fb035f348da3aa";
}

and this is my login check

$select_user_sql = $this->db->selectSQL("*", "tdic_users", "email = '". $email ."' AND password = '". sha1($this->main->SaltMe($password)) ."'");

No matter what I type in the password field I end up with:

1c2c2961d35148e8dfc83c7b31cf144f0987de9d

Which is also what my encrypted password is. But it is not good that I can type whatever I want to match the password.

The login form’s actions is validatelogin.php which contain:

$user = new UserHandling();
$user->UserLogMeIn($_POST["login_email"], $_POST["login_password"]);

And the login function:

 /**********************************************************
     * User login function
     * 
     * @param string    | User's email
     * @param string    | User's password
     **********************************************************/
    function UserLogMeIn($email, $password) {

        $select_user_sql = $this->db->selectSQL("*", "tdic_users", "email = '". $email ."' AND password = '". sha1($this->main->SaltMe($password)) ."'");
        $select_user_result = $this->db->SQLquery($select_user_sql);

        if(mysql_num_rows($select_user_result) < 1) {
            $this->main->txtOutput("Wrong email or password", "TXT_ERR"); //The user typed something wrong.
        } else { 
            while($row = $this->db->SQLfetch($select_user_result)) {
                /*** We will check if user have activated the profile ***/
                if($row["activated"] == 0) {
                    $this->main->txtOutput("Your profile haven't been activated! You need to click on the activation link in the email you recieved upon registration.", "TXT_ERR"); //The user haven't activated the new profile. This is necessary for security / spamming reasons
                    $this->main->JSredirector("http://localhost/test/login.php", 5); //Redirect the user back from where he/she came from
                } else {
                    /*** Everything is in order and we will let the user in ***/

                    $_SESSION["usr_logged_in"] = 1;
                    $_SESSION["user_email"] = $row["email"];
                    $_SESSION["user_id"] = $row["user_id"];
                    $_SESSION["user_name"] = $row["name"];

                    /*** This will just update the last login field in the user table ***/
                    $fields = array("user_last_logged_in" => time());
                    $update_user_sql = $this->db->updateSQL('tdic_users',  'email = "'. $email .'"', $fields);
                    $this->db->SQLquery($update_user_sql);
                }
            }
        }
    }

I can not figure out where the string is set so it always matches!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:29:57+00:00Added an answer on June 6, 2026 at 10:29 pm

    U return a constant string when salting pass. Try

    function SaltMe($pass) {
       // Pass salted with Secret keyword encrypted with sha1 
       return "4cefe49883b6dd1a00565e2a80fb035f348da3aa" . $pass;
    }
    

    Also as SLaks said, u have SQLinj. And it is better to use PDO or mysqli database functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to crawl a secure page (https) such as google with curl but
I'm trying to use mysql_real_escape_string() to secure a log in form. Using this code:
i am currently trying to secure my Objective-c application with a password. What I
I'm trying to secure WCF service with https and username & password. I'm using
I'm trying to make a normal username/password login form secure, without needing HTTPS. My
What I'm trying to do is to secure my service. To do this I'm
I'm trying to secure a WCF service using windows accounts. The service should run
I am trying to secure communications via SSL/TLS for one of our Web Service
I am trying to secure my Flex application within my Java web application. Currently
I'm trying to secure an application so that users can only see objects which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.