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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:17:14+00:00 2026-05-18T11:17:14+00:00

I was reading this tutorial for a simple PHP login system . In the

  • 0

I was reading this tutorial for a simple PHP login system.

In the end it recommends that you should encrypt your password using md5().

Though I know this is a beginners’ tutorial, and you shouldn’t put bank statements behind this login system, this got me thinking about encryption.

So I went ahead and went to (one of the most useful questions this site has for newbies): What should a developer know before building a public web site?

There it says (under security) you should:

Encrypt Hash and salt passwords rather
than storing them plain-text.

It doesn’t say much more about it, no references.

So I went ahead and tried it myself:

$pass = "Trufa";
$enc = md5($pass);

echo $enc; #will echo 06cb51ce0a9893ec1d2dce07ba5ba710

And this is what got me thinking, that although I know md5() might not the strongest way to encrypt, anything that always produces the same result can be reverse engineered.

So what is the sense of encrypting something with md5() or any other method?

If a hacker gets to a password encrypted with md5(), he would just use this page!.

So now the actual questions:

  1. How does password encryption work?

I know I have not discovered a huge web vulnerability here! 🙂 I just want to understand the logic behind password encryption.

I’m sure I’m understanding something wrong, and would appreciate if you could help me set my though and other’s (I hope) straight.

How would you have to apply password encryption so that it is actually useful?

  1. What about this idea?

As I said, I may/am getting the whole idea wrong, but, would this method add any security in security to a real environment?

$reenc = array(
 "h38an",
 "n28nu",
 "fw08d"
 );

$pass = "Trufa";

$enc = chunk_split(md5($pass),5,$reenc[mt_rand(0,count($reenc)-1)]);

echo $enc;

As you see, I randomly added arbitrary strings ($reenc = array()) to my md5() password “making it unique”. This of course is just a silly example.

I may be wrong but unless you “seed the encryption yourself” it will always be easily reversible.

The above would be my idea of “password protecting” and encrypted password, If a hacker gets to it he wont be able to decrypt it unless he gets access to the raw .php

I know this might not even make sense, but I can’t figure out why this is a bad idea!


I hope I’ve made myself clear enough, but this is a very long question so, please ask for any clarification needed!

Thanks in advance!!

  • 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-18T11:17:14+00:00Added an answer on May 18, 2026 at 11:17 am

    You should have an encryption like md5 or sha512. You should also have two different salts, a static salt (written by you) and then also a unique salt for that specific password.

    Some sample code (e.g. registration.php):

    $unique_salt = hash('md5', microtime()); 
    $password = hash('md5', $_POST['password'].'raNdoMStAticSaltHere'.$unique_salt);
    

    Now you have a static salt, which is valid for all your passwords, that is stored in the .php file. Then, at registration execution, you generate a unique hash for that specific password.

    This all ends up with: two passwords that are spelled exactly the same, will have two different hashes. The unique hash is stored in the database along with the current id. If someone grab the database, they will have every single unique salt for every specific password. But what they don’t have is your static salt, which make things a lot harder for every “hacker” out there.

    This is how you check the validity of your password on login.php for example:

    $user = //random username;
    $querysalt = mysql_query("SELECT salt FROM password WHERE username='$user'");
    while($salt = mysql_fetch_array($querysalt)) {
        $password = hash('md5',
              $_POST['userpassword'].'raNdoMStAticSaltHere'.$salt[salt]);
    }
    

    This is what I’ve used in the past. It’s very powerful and secure. Myself prefer the sha512 encryption. It’s actually just to put that inside the hash function instead of md5 in my example.

    If you wanna be even more secure, you can store the unique salt in a completely different database.

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

Sidebar

Related Questions

In this tutorial I am reading , Dave Ward creates a page that shows
After reading this discussion and this discussion about using CrashRpt to generate a crash
I am reading this tutorial on Haskell . They define function composition as the
Reading this question I found this as (note the quotation marks) code to solve
Reading this post has left me wondering; are nightly builds ever better for a
Reading this blog post about HttpOnly cookies made me start thinking, is it possible
After reading this question , I was reminded of when I was taught Java
After reading this description of late static binding (LSB) I see pretty clearly what
After reading this answer: best way to pick a random subset from a collection?
After reading this on the question How do I uniquely identify computers visiting my

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.