To encrypt a password using SHA1 in PHP, you can use the sha1()
function. Here's an example:
main.php167 chars6 lines
In this example, the original password is "password123". The sha1()
function takes the password as input and returns the SHA1 hash of the password. The resulting hash is assigned to the variable $encrypted_password
.
The output of the program would be:
main.php92 chars3 lines
Note that SHA1 is not considered a secure cryptographic algorithm for password storage, and it is recommended to use stronger algorithms such as bcrypt or Argon2 instead.
gistlibby LogSnag