1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)

Using Crypt to Encrypt Password in PHP

Sometimes we need to encrypt a password hash in php before inserting it into the database. The code below will reveal this information.


Tip: Click on images to make them larger. If you find anything wrong on this page or need further assistance please comment below or contact me. 🙂
<?php $passwordtohash = 'mypassword'; $hash = crypt($passwordtohash); echo $hash; echo $passwordtohas; ?>

Explaining the Crypt Code and Process

The php variable of $pass is holding within it “hash”. We then take the variable $passwordtohash and put the crypt function on it and store it in another variable called $hash.

We then echo out both the $hash and the $passwordtohash to see what they look like.

Subscribe To My YouTube Channel:

Uses of PHP Crypt

Remember there is no way to decrypt the algorithm.  So this would only be good if you wanted a use to enter something to match something that is encrypted like a password hash. You would also want to encrypt your password with something like



More info on php crypt

Using Crypt to Encrypt Password in PHP was last modified: January 11th, 2021 by Maximus Mccullough

Please like, share and subscribe.

Advanced Programming Made Easy

I hope you enjoyed the article. If I was able to help you please consider a tip for the content.

One Time Tip

more tips

Reoccuring Tips


Cool People Share:
PHP Web Development

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.