How to show passwords as asterisks "*"

Discussion in 'PHP' started by Marks & Lesters, Aug 21, 2008.

  1. #1
    I have a page wherein you can view users and their passwords which is shown clearly. What i want to do is show the passwords in asterisk "*" to privatize things...

    If possible could i also do it in the database(PhpMyAdmin)....
    Im using Wampserver....
     
    Marks & Lesters, Aug 21, 2008 IP
  2. adultwordpressthemes

    adultwordpressthemes Active Member

    Messages:
    102
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    83
    #2
    you could output the password into an input box
    <input type="password" values="your password goes here" /> 
    HTML:
     
    adultwordpressthemes, Aug 21, 2008 IP
  3. nice.wallpapers

    nice.wallpapers Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Hi ,

    Please Use <input type=? , to type="password" not type="text".


    Thanks,
     
    nice.wallpapers, Aug 21, 2008 IP
  4. Joseph S

    Joseph S Well-Known Member

    Messages:
    1,373
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #4
    You should encrypt their passwords..
     
    Joseph S, Aug 22, 2008 IP
  5. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Yeah.. md5($password) before saving it in the DB.

    Or you could just, when you print the passes count the string, make a for loop that echoes the asterixes.
     
    elias_sorensen, Aug 22, 2008 IP
  6. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #6
    Using TAG INPUT .. and type="password"


    :)
     
    ghprod, Aug 22, 2008 IP
  7. jack_ss

    jack_ss Guest

    Messages:
    94
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Whether or not it's the right way to be storing your passwords (I recommend crypt()), you can easily replace characters with asterisks in PHP like so:
    echo preg_replace("/./", "*", $pass);
    PHP:
     
    jack_ss, Aug 22, 2008 IP
  8. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #8
    This is like MD5 ?
     
    ghprod, Aug 23, 2008 IP
  9. jack_ss

    jack_ss Guest

    Messages:
    94
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Not at all. That code replaces every character in your $pass variable to asterisks ("*").
     
    jack_ss, Aug 24, 2008 IP
  10. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #10
    Wow . good implement of preg_match_all :)

    btw its real time?

    or server side?
     
    ghprod, Aug 25, 2008 IP
  11. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #11
    Alriiight... I think he got the hint. How many more people are going to repeat this?

    Avoid regular expressions whenever possible, they're slow. You can do it this way instead:
    
    $password = str_repeat('*', strlen($password));
    
    PHP:
    (This is about 3 times faster)

    It's actually preg_replace(). And your question makes no sense. But it's both, real time, and server side. (Like all PHP code).
     
    nico_swd, Aug 25, 2008 IP
  12. jack_ss

    jack_ss Guest

    Messages:
    94
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #12
    /me = Perl background.

    Yes, PHP code is always sever side. If by "real time" you mean browser side, the answer is no.
     
    jack_ss, Aug 25, 2008 IP
  13. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #13
    don't get the point on putting stars on the screen if they cant do much with it? if its a password change box, don't wast time calling passwords and encrypting them just tell them to insert the old password as well!
     
    cornetofreak, Aug 25, 2008 IP
  14. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #14
    cornetofreak: but actually, the passwords SHOULD be encrypted before inserting them to the DB.
     
    elias_sorensen, Aug 25, 2008 IP
  15. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #15
    Thnx for ur Correction :)
     
    ghprod, Aug 26, 2008 IP
  16. nabz245

    nabz245 Well-Known Member

    Messages:
    677
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #16
    Before entering the passwords to the db... use md5() which will encrypt them. (Makes your website a lot more secure).
    Then when validating... MD5 the inputted password then compare it the password located in the DB.
     
    nabz245, Aug 26, 2008 IP
  17. Dman91

    Dman91 Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #17
    actually dont just use md5 for encryptions, use a salt too. and solution posted by nico is the best :)
     
    Dman91, Aug 27, 2008 IP