Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you need to use mysqli_real_escape_string for encrypted values?

I'm working on a project called ThePeopleHubProject, and on the registration you need to input a password.

Do I need to secure the passwords from SQL injection if they are encrypted?

I use crypt(sha1()) as a encryption method.

Thanks, Thomas.

like image 847
user2999920 Avatar asked Nov 23 '25 15:11

user2999920


1 Answers

You don't need to, you can either restrict your input field of password to allow/accept what combination it needs.

<input type="password" name="password">

PHP Code:

<?php

   if(isset($_POST['password'])
     $password = htmlentities($_POST['password']) // This will ensure any html characters entered to their equivalent value.
     md5 or sha1($password);

To basically sum-up my answer, encrypting is more than enough you don't need to worry about sql-injection here.

like image 80
Thalaivar Avatar answered Nov 26 '25 04:11

Thalaivar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!