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 6816293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:54:30+00:00 2026-05-26T20:54:30+00:00

I have a php function in a php page called encrypt_password that I use

  • 0

I have a php function in a php page called encrypt_password that I use when processing a registration form:

function encrypt_password($password){

    $salt  = sha1(md5($password));
    $password = md5($password.$salt);

    return $password;
}

I try to use it again for when I process the login form but I get a different result.

I get the correct result just by not calling this function and instead just calling:

$salt  = sha1(md5($password));
$password = md5($password.$salt);

directly on my process_login page. Why would I get a different result by calling encrypt_password?

I hope I have explained this clearly enough!
Thanks!

  • 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-05-26T20:54:31+00:00Added an answer on May 26, 2026 at 8:54 pm

    I simply cannot believe this to be true. You say you have two pages, one with a registration form and one with a login form.

    They both have to encrypt the password the user has posted.

    There can be a number of things wrong here, depending on how you find they don’t match. Do you just try to login and see an error that your password is wrong? Or did you echo the password hash after a call to encrypt_password? It would be nice to have done that to shown us a hash of the password ‘test’, from both the registration page and the login page. Perhaps someone could’ve seen a pattern.

    Anyway, let me guess:

    1. You enter the password incorrectly.
    2. You have created this user you’re testing it with, with an older version of your encryption function. Perhaps you only used md5(password) to register, then you read somewhere that was unsafe and added a salt. Now you’re comparing two different hashes for the same password, since the password is stored in the database using the old hashing function.
    3. You set $password with $password = $_POST['password']; I guess. On both pages, I guess too. Are those statements on both pages typo-free? No $password = $_POST['pasword']; there? And are both <input> elements named “password”?
    4. Typos also go for the $encrypt_password function. Do you define it on both pages, or do you include it from another file? (You should!) If they exist in both files, do they match letter by letter? Copypaste it to test this, and if it works, thank me and put it in an include afterwards, and let it be a lesson.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that I use on index.php page and I would like
I have a php page that calls and runs a method called pagestart() in
I have a php function that's run when a build.php page is loaded and
I have a page called index.php which is calling a function writelog in includes/Logger.php
I have a php function I wrote that will take a text file and
I have a PHP function that takes a variable number of arguments (using func_num_args()
I have a PHP function that requires can take 3 parameteres... I want to
Is it possible to have a PHP function that is both recursive and anonymous?
I have written a PHP function to take a video embed code that has
I have a drop shadow function in PHP. In my php page, I have

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.