43: Hashing and de-hashing data using PHP | PHP tutorial | Learn PHP programming

Sdílet
Vložit
  • čas přidán 5. 09. 2024
  • Hashing and de-hashing data using PHP | PHP tutorial. In this lesson you will learn about database data security, and how to hash and dehash data using PHP. In PHP we have a hash function which uses bcrypt, in order to protect data provided by our users.
    Login system tutorial (link starts at hashing part): • Video
    ➤ GET ACCESS TO MY LESSON MATERIAL HERE!
    First of all, thank you for all the support you have given me!
    I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
    I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.
    I hope you will find it helpful :)
    Material for this lesson: / lesson-material-42361704

Komentáře • 135

  • @w3slley_
    @w3slley_ Před 6 lety +19

    I have been watching the series so far and I learned a lot since. Thank you for doing such well done tutorial and putting it on the web for free. Technology is powerful and its effectiveness is enhanced by people like you sir.

  • @fitimzenuni5036
    @fitimzenuni5036 Před 5 lety +39

    De-hashing is imposible mathematicly that is why it is safe.
    Hashing uses functions that can't be inverted so when u use the first parameter that is the actual pass and the second parameter that is the same pass just hashted it grabs the first parameter hashes it and compares it to the second parameter and if that is true it returns "1",that is how i think password_verify() works,since hashing is not an invertable function.
    BTW still the greatest PHP tutorials on youtube.

    • @Dani_Krossing
      @Dani_Krossing  Před 5 lety +12

      You are absolutely right :) I explained the process wrong in this video.

    • @qendrimvrella9962
      @qendrimvrella9962 Před 5 lety +1

      Nice 😊

    • @MrNsaysHi
      @MrNsaysHi Před 4 lety

      But how come the password_hash() gives different outputs for the exact same input?
      It's not the same as using a sha1() function and then manually comparing it with the input.. Which is better? and why?

    • @malloumjr
      @malloumjr Před 4 lety

      @@MrNsaysHi For security dear, if he can't give different in any second, hacker can have solution to hack

    • @MrNsaysHi
      @MrNsaysHi Před 4 lety

      @@malloumjr
      But isn't hashing a one way function that always gives the same output for the same input?

  • @wywlf6912
    @wywlf6912 Před 2 lety +2

    literally the best video out there explaining hash and dehash without spending more than 10 minutes

  • @lucasarif4387
    @lucasarif4387 Před 7 lety +23

    Active channel making php tutorials? Unheard of - and awesome

  • @NickYea
    @NickYea Před 4 lety +3

    This is an amazingly simple, informative and pleasurable video to watch, thanks for making it so well!

  • @scottguo195
    @scottguo195 Před 7 lety +51

    You don't mean that you can actually DE-hash a hashed string right? If a hash can be de-hashed, it's not a hash anymore.

    • @petertester915
      @petertester915 Před 5 lety +2

      I'd recommend watching the video to the end.

    • @lollisko
      @lollisko Před 3 lety +1

      No it doesnt dehash it at all. Theres a ”salt” at the beginning of gibberis marked with two dollar marks. It’s used on original hash (rest of the string) for making it more complex and random. Password_verify() uses that same salt for hashing now inputted password and combines it to hash picked from database, and if this matches - password was correct.

  • @olegpristashkin9078
    @olegpristashkin9078 Před 3 lety +1

    How can we apply hash when the quantum computer will be finished? So can we assume, that the password hashing will be only a temporary method of protection? Am I right if I say that a good method of protection, in this case, is to limit attempts to log in up to 3 times an hour to avoid brut force?

  • @nebiyuyouhannes6047
    @nebiyuyouhannes6047 Před 4 lety

    this is the best channel for learning front end and back end thank you for this

  • @mohammadabdulkarim7750
    @mohammadabdulkarim7750 Před 7 lety +6

    You are the best man .I suggest to make some project using all you learned to us such as inventory website or something like that .it will help us alot and you can make it payable and will buy it .
    I understand every word you said in HTML/CSS curse,PHP and OOP PHP .

    • @mmforyou
      @mmforyou Před 6 lety +1

      Please make it free..

    • @GIGATHEBOT
      @GIGATHEBOT Před 6 lety

      in HTML/CSS *"CURSE"*

    • @frosttree7236
      @frosttree7236 Před 5 lety +1

      Completely worth to buy! Please make some project tutorials!!!

  • @zziq0437
    @zziq0437 Před 2 měsíci

    THANKS HARITH FOR SHARING

  • @Mustafa-gd2rp
    @Mustafa-gd2rp Před 7 lety +15

    I don't think password_verify actually dehashes, instead it hashes the input and uses an algorithm to see if it corresponds to the given hash (giving all the necessary like salt and cost)

    • @thelavina
      @thelavina Před 6 lety +2

      each time you hash something its always different, so how would the password_verify function know in which exact way to hash the inputted password then?

    • @hechuan5075
      @hechuan5075 Před 6 lety +1

      its not always different, for example, MD5 you see when you download a file, if you MD5 that file, you will get the MD5 result, otherwise its pointless. say SHA256("nihao") will always yield the same result.

    • @wegvS
      @wegvS Před 6 lety

      Actually it is never different. From Wikipedia: "A hash procedure must be deterministic-meaning that for a given input value it must always generate the same hash value"

    • @fitimzenuni5036
      @fitimzenuni5036 Před 5 lety +1

      a function with the same input can not produce more than one output else it is not a function at least i think i learned that on a calculus class.

  • @goddessgermanika2466
    @goddessgermanika2466 Před 3 lety +2

    Hi Dani, thank you very much for all those tutorials! In regards to passwords, what is your opinion about salting passwords? I was told that certain companies add it to hashed passwords. Do you think it would be good idea? and if so... do you have a tutorial for it by any chance?

  • @robinsonenrique2466
    @robinsonenrique2466 Před 6 lety +1

    Is better use BCRYPT or password_Default ?

  • @vikaspadaliya2606
    @vikaspadaliya2606 Před 7 lety +5

    Can't find no.41 and 42 , are they missing?

    • @ashkanahmadi
      @ashkanahmadi Před 3 lety

      czcams.com/play/PL0eyrZgxdwhwBToawjm9faF1ixePexft-.html

  • @maherhanna2432
    @maherhanna2432 Před 2 lety

    Your tutorials are very good and simple to understand thank you very much

  • @keanutype0896
    @keanutype0896 Před 2 lety

    i have questions:
    1. so basically when i Password_Has the first input i have, it will encrypt the text....but whatever i input there(ex: Test123) it IS STILL "Test123"? just being randomize when you echo it?
    2. is Password_Verify() similar to If and AND comparison statement but it will decyper first the encrypted password?
    like in If statement, you are trying to compare it like:
    if($input == $hashedPwdInDb){ echo "1";}
    but unlike a regular If Statement, it has the function to decyper the hashed password then compare it to the $input?
    i hope i worded this correct. sorry english wasn't my first language. great tutorial!

  • @mmelimahlobo7656
    @mmelimahlobo7656 Před rokem

    Hie Daniel your teaching is amazing have you considered creating on lengthy tutorial that we can purchase in Udemy?

  • @amoghdatar2726
    @amoghdatar2726 Před 6 lety +1

    *Will you pls reply to tell which is the **_BEST_** and **_SAFEST_** method of hashing passwords? BCrypt, Hashing It Two Times, S256, etc.?*

    • @Dani_Krossing
      @Dani_Krossing  Před 6 lety +1

      No just use BCrypt once :) BCrypt is automatically updated if it becomes outdated, so it will always be safe.

  • @abhikhan1313
    @abhikhan1313 Před 3 lety

    hey hi dani the link you have given in your description is showing the video is private

  • @meruBB
    @meruBB Před 2 lety

    simple and easy. Thanks bro

  • @CredixNetwork
    @CredixNetwork Před 7 lety

    Hello Daniel! Can I ask you a quick question? What color syntax/theme you're using? Thanks for the answer and for the great tutorial!

  • @zz98456
    @zz98456 Před 5 lety

    Thanks! Used your video to learn how to do test assignment.

  • @BeyondReality
    @BeyondReality Před 10 měsíci

    That doesn‘t work in my case. When I copy the hash and paste it into a variable, the verify method returns an invalid password 😢

  • @MB-zj3er
    @MB-zj3er Před 2 lety

    Very helpful video. Thank you!

  • @RichardSantos-bk9vz
    @RichardSantos-bk9vz Před 3 lety

    Thanks now i understand how to use this hash 😁

  • @bigywhile8164
    @bigywhile8164 Před 3 lety

    I really appreciate your great help. Thank you really much!

  • @yukihyo8394
    @yukihyo8394 Před 7 lety +3

    Is it also save to hash a password with sha512? And then for comparing them, instead of dehashing you hash the input and compare them with the database. Love this method as well tho :D

    • @gewoonpatatmayonais
      @gewoonpatatmayonais Před 7 lety +3

      Nope, that is definitely not safe! Whenever a hackers steals the hashed passwords from your database, he can dehash it (with lookup tables) and get the full password from that one user.
      Bcrypt adds a randomized 'salt' to it so that it is (almost) impossible for the hacker to retrieve the original value.
      So, don't just hash passwords with sha or md5 and store them in a database.

    • @gewoonpatatmayonais
      @gewoonpatatmayonais Před 7 lety

      For example, hash a password with sha512. Copy the value and paste it in the text area at this site: crackstation.net/
      For simple passwords, you can get the value back. More complex passwords, however, may not be found.

    • @yukihyo8394
      @yukihyo8394 Před 7 lety

      what if you hash it like 3 times? using sha512, so you are hashing a hash?

    • @gewoonpatatmayonais
      @gewoonpatatmayonais Před 7 lety

      King Otten you can, doesnt make it more secure. Can still be looked up in a rainbow table, hence why the salting process in bcrypt

    • @Dani_Krossing
      @Dani_Krossing  Před 7 lety +1

      name is absolutely right here. You should not use either md5, sha256 or sha512, since hackers figured out how to solve these algorithms long time ago. Thats why bcrypt is so awesome, because if hackers somehow (which is very unlikely) figure out how to bypass it, then bcrypt will just get updated and yet again be safe to continue using.

  • @femaledeer
    @femaledeer Před 3 lety +1

    If two different users create the same user name and password, how does the correct user get verified when logging in? You said two different hashes would be produced when the user registers. Is there a magic trick to determine the correct user to validate?

    • @MB-zj3er
      @MB-zj3er Před 2 lety

      Don't allow duplicate user names when accounts are created. ;)

  • @filodox21
    @filodox21 Před 7 lety

    Hello, your channel is fantastic. Did you know how many php classes you have?

  • @GerritforBazeja
    @GerritforBazeja Před 5 lety +1

    You are wonderfull for me. I'm trying to make our website website with better inlog and more. All in php and mysqli.
    Your lessons are very helpfull. (I'm 60 years old now. first I did this all in dramweaver.
    grtGrrt

  • @MrBondSanjay1
    @MrBondSanjay1 Před 3 lety

    Please Dani Can you help me ? Code not work with me .I am using Atom.

  • @pianoLee-sx9dx
    @pianoLee-sx9dx Před 5 lety

    I don't think that you can get someone to enter a password and then check it in the database? I think once you hash the new password, it will always be different from the database and won't work...

  • @magicalbhakuni
    @magicalbhakuni Před 7 lety

    learned a lot from this video.

  • @isaiahdaniel2522
    @isaiahdaniel2522 Před 5 lety +1

    Please the password hash did not work when i type it, any help plz

  • @jessm.sandler7187
    @jessm.sandler7187 Před 10 měsíci

    video on link is not available bro

  • @pianoLee-sx9dx
    @pianoLee-sx9dx Před 6 lety

    I forgot to ask.. do you still need to salt the password? I read somewhere that you still have to

  • @PHPRunnerTipsAndTricks

    So what is password_verify really doing? Could you test password_hash(input) with passwordinDb with an if statement?

  • @1988proxy
    @1988proxy Před 5 lety

    Thank you very much for your videos!!!

  • @user-oo7nt5qg2w
    @user-oo7nt5qg2w Před 3 lety

    When is the link to the login system tutorial? The link is not working for me?

  • @yukii_kamishiro
    @yukii_kamishiro Před 4 lety

    Thank you, this help me alot.

  • @alizaman5716
    @alizaman5716 Před 7 lety +3

    HELLO SIR..
    I M ASP.NET C# DEVELOPER. I LOVE UR TEACHING STYLE N CLAERLY I GET UR ALL PHP LECTURES. THANK YOU SOO MUCH FOR UR EFFORTS
    PLZ UPLOAD THE 41 42 VIDEOS IN THS SERIES... :)

  • @gabrielfono844
    @gabrielfono844 Před 3 lety

    thanks so much
    thanks so much

  • @abdulkarimalbaik3873
    @abdulkarimalbaik3873 Před 5 lety

    what is type of String after hashing (String , int or byte) ????

  • @willthe5135
    @willthe5135 Před 5 lety

    How can I hash with AES 256 bit encryption? Or is bCrypt already that strong?

  • @kestonsmith1354
    @kestonsmith1354 Před 3 lety

    You made the login video private so I can't view it.

  • @kirilmladenov7852
    @kirilmladenov7852 Před 6 lety

    Guys, I am a little confused ( : What is the difference between hashing, real_escape function and prepared statements?

  • @carlbaiden191
    @carlbaiden191 Před 4 lety

    The 43rd video is private...how can i get it pleas?

  • @derxramos7906
    @derxramos7906 Před 5 lety

    Great tutorial :) I'd just like to ask how can I use that encrypted password to send email in PHPMailer? Thank you.

  • @dombiekong4733
    @dombiekong4733 Před 4 lety

    what about random salt?

  • @devsabuj4818
    @devsabuj4818 Před 3 lety

    is it possible decode password hash

  • @rohansaand2023
    @rohansaand2023 Před 7 lety

    very informative, Thanks :)

  • @NoThoughtAllFeels
    @NoThoughtAllFeels Před 4 lety

    How did you get that index.php file in the first place

  • @ambdcot3828
    @ambdcot3828 Před 4 lety

    Hey, video 44 is private, is this ok?

  • @hachij_
    @hachij_ Před 6 lety

    is this updated video? cuz, last time i checked is different from this one pls explain which parts you updated?

    • @Dani_Krossing
      @Dani_Krossing  Před 6 lety

      This video is updated and the most recent version of data hashing.

  • @AndyChamberlainMusic
    @AndyChamberlainMusic Před 4 lety

    link is broken

  • @nsoftltd6878
    @nsoftltd6878 Před 3 lety +1

    Tnx bro

  • @yanghyunmo1929
    @yanghyunmo1929 Před 4 lety

    Can I ask where is the full version of Login system tutorial? I remember you had it before in the tutorial.

    • @rashedulhasan5372
      @rashedulhasan5372 Před 4 lety

      yap..link isn't working. Would be useful to see hashing in action

    • @Venezuelangel
      @Venezuelangel Před 4 lety

      It's been set to private. Probably the creator was catching a lot of heat for making it procedural instead object-oriented? I dunno. Maybe he wants to monetize it?

    • @gabrielvoss6251
      @gabrielvoss6251 Před 4 lety

      @@Venezuelangel no it's just on another channel @ZbII

  • @comfortbatcall
    @comfortbatcall Před 6 lety

    Me it's always saying login=error in the url help how can it fix?

  • @mariusmihailionte3359
    @mariusmihailionte3359 Před 7 lety

    are you uploading again videos that you posted in 2015?

  • @hanishaarora9590
    @hanishaarora9590 Před 6 lety

    super cool!!

  • @randalfjohn9848
    @randalfjohn9848 Před 2 lety

    This is lesson 43.. how can I get from lesson 1 to the end.. please 😭

  • @nicolesantos603
    @nicolesantos603 Před rokem

    5:45 dehash

  • @michaellussem1777
    @michaellussem1777 Před 4 lety

    Link to login-Tutorial isn‘t working

  • @adnanjan1298
    @adnanjan1298 Před 5 lety

    respected sir, i get a lot of knowledge from your lessons: now i have a problem, when i practice of password_hash function i receive this error message in chrome browser: {{{{{{Fatal error: Call to undefined function PASSWORD_HASH}}}} kindly help me.

  • @xbond2089
    @xbond2089 Před 3 lety

    it dose not work when stored in database

  • @westfield90
    @westfield90 Před 6 lety

    Superb

  • @anshultiwari2704
    @anshultiwari2704 Před 5 lety

    Suppose i have to store chat messages in my database in a secure and hashed format how can I dehash those text messages whenever it is displayed back to the user??
    Can someone tell me a better way to encrypt text messages in php and MySQL database

    • @Jack-vv7zb
      @Jack-vv7zb Před 4 lety +1

      You'll have to encrypt them instead of hash them. Encrypt means it uses a key and so they can be decrypted. It's less safe than hashing of course because if someone gets hold of the key then they can access everything.

  • @Akosiyawin
    @Akosiyawin Před 5 lety

    I'm getting an error says 'call to undefined function password_hash()' Idk why I did exactly what you does, any thoughts about it?
    Edit:I'm using 1.8.2 version of xampp and 5.4.22 Php Version does it affect my program?

    • @Dani_Krossing
      @Dani_Krossing  Před 5 lety +1

      Yes, you should definitely upgrade. A lot of changes were made since then. PHP is all the way at 7.0+ in its version now. It should fix your undefined error.

    • @Akosiyawin
      @Akosiyawin Před 5 lety

      @@Dani_Krossing yep thank you very much. That's exactly what I did, coz back on your tutorial I saw the version of your Xampp was compiled on 2015 while mine is 2013, didn't notice that I was using an old version of xampp hehe, Thank you sir, I'm almost finish with this tutorial, have a good day.

  • @Kuminlul
    @Kuminlul Před 5 lety

    so how do i hash the username with the same method like with the password?

    • @definedbass
      @definedbass Před 5 lety

      method is the same but why would you hash the username? Username is public in most scenarios

  • @user-jc4fp7sv1v
    @user-jc4fp7sv1v Před 2 lety

    link does not work!!!

  • @renzjosefflacostales4015

    Sir is there any chance to view the normal password ni phpmyadmin coz i don't know to view the normal password in database.it will be hard especially when I forgot the password :( thanks in advance sir

    • @Dani_Krossing
      @Dani_Krossing  Před 5 lety

      No that would defeat the purpose of hashing it hehe. The point is that we SHOULD NOT be able to see the password in the database in case a hacker gains access.

  • @rahman_athu
    @rahman_athu Před 5 lety

    Password verify always returning false

  • @falconeye1594
    @falconeye1594 Před 7 lety

    42 is miss bro.

  • @riteshsingh214
    @riteshsingh214 Před 5 lety

    can you make a video on how to create a sub-domain dynamically through PHP i have done the same it is creating domain too but in root folder it is creating problem
    following is the code

    but in root folder it is creating not creating the folder of same name as entered by user it is creating folder named as'$domain.example.in'.
    Please help
    Thanks in advance.

  • @marshal523
    @marshal523 Před 6 lety

    Please make a tutorial on how to create a contact form using php

  • @PabloGnesutta
    @PabloGnesutta Před 4 lety

    The login video in the description of this video is broken T_T

    • @ashkanahmadi
      @ashkanahmadi Před 3 lety

      czcams.com/video/LC9GaXkdxF8/video.html

  • @piotrpytkowski1542
    @piotrpytkowski1542 Před 3 lety

    So about this Login system tutorial (link starts at hashing part): czcams.com/video/xb8aad4MRx8/video.htmlm42s - the movie is private, is this will be avaible?

  • @hachij_
    @hachij_ Před 7 lety

    good

  • @AugerHybrid
    @AugerHybrid Před 4 lety

    OMG it worked but sequence is "This video is private".

    • @ashkanahmadi
      @ashkanahmadi Před 3 lety

      czcams.com/video/LC9GaXkdxF8/video.html

  • @aaammm1888
    @aaammm1888 Před 4 lety +1

    44: vidoe on pvt whyyyyyyyy came so far

    • @ashkanahmadi
      @ashkanahmadi Před 3 lety

      czcams.com/video/LC9GaXkdxF8/video.html

  • @connorg8465
    @connorg8465 Před 7 lety

    It thought the whole point of hashing was you can never "de-hash" it? You can only re-hash new information and compare with the saved/old hash... I thought it was encryption and decryption where you could get the information back

    • @inferno7181
      @inferno7181 Před 6 lety

      Connor Gaunt it doesn't. It just hashes the password with the same salt and compares it to the one given.

  • @ArifBillahOnGoogle
    @ArifBillahOnGoogle Před 3 lety

    The title is rather misleading. You don't "de-hash" with password_verify()

  • @shaikansar1315
    @shaikansar1315 Před 6 lety

    when iam logging it takes any password and logging me in

  • @cjvaans4484
    @cjvaans4484 Před 4 lety

    You talk way too fast as if the words are stitched together. Still, I thank for you these free tutorial videos.

    • @ashkanahmadi
      @ashkanahmadi Před 3 lety

      You can turn on the subtitle and change the playback speed to 0.75. That should make it clearer for you

  • @JustinTheVlogger
    @JustinTheVlogger Před 3 lety

    Greate tutorial, but next please talk slow, cause some of your words are unhearable.

  • @boiski
    @boiski Před 4 lety

    I tried to crack the password. Did it in 3 seconds

  • @inzMBL
    @inzMBL Před 6 lety

    You talk funny

  • @thezvid
    @thezvid Před 4 lety

    This Video is Private

  • @Sean.Q
    @Sean.Q Před 4 lety

    PAYWALLED Correct way ??? BS... CZcams money isn't enough for you? You really need to fish for a buck a month on Patreon?

  • @adityachopra3759
    @adityachopra3759 Před 6 lety

    Stop using the term "DE-HASH". It is invalid. You can't DE-HASH.