Md5 hash: Encryption of a string

$str="Hello";
echo md5($str);
The output of the above code will be
8b1a9953c4611296a827abf8c47804d7
md5 returns the hash of a string. This is used to encrypt strings and particularly encrypting the passwords of the user. This function returns the encrypted string by using RSA Data Security Inc.

Inputs

String : for which md5 to be generated
raw : Optional , TRUE : 16 chars binary format . FALSE : 32 chars hex number ( default )

The length of the password after encryption is 32 char if the raw is set to FALSE ( default )
If you are using database table to store password then the password field should be minimum 32 char length. Read sql_update command to know more about storing encrypted password in table.

md5 encryption is not so useful to store passwords and other sensitive data. This is just minimum standard of encryption only.

md5 encryption is one way only, there is no standard method to generate the source or the original string from the hash of the string. So passwords can't be retrieved and it can only be reset.

Here is a script to display the md5 output for a given string.

Maximum 16 char length allowed
Use only alphanumeric characters


Example: Validating File Integrity

$file = 'example.txt';
$hash = md5_file($file);
echo $hash;

Example: Salting MD5 Hash

$password = 'mypassword';
$salt = 'random_salt';
$hash = md5($password . $salt);
echo $hash; //c945424c71ab824908348bb4f8a1ec38
Security Warning:
  • MD5 is vulnerable to attacks; use stronger functions like hash('sha256') or password_hash().

  • String Functions password_hash() function to work with different encryptions
    Subhendu Mohapatra — author at plus2net
    Subhendu Mohapatra

    Author

    🎥 Join me live on YouTube

    Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



    Subscribe to our YouTube Channel here



    plus2net.com











    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
    ©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer