Whats the best way to encrypt passwords ?

Discussion in 'PHP' started by xkaser101, Aug 8, 2011.

  1. #1
    I was thinking and searching about this topic all day I am just curious, :confused:

    If you know whats the best way to crypt information and still be able to decrypt them later own safely Please let me know
    .
    And wouldn't other people be able to decrypt data just like I did ?



    Thanks in advance,
    Kind Regards,
    Issa Shamoun.
     
    xkaser101, Aug 8, 2011 IP
  2. jazzcho

    jazzcho Peon

    Messages:
    326
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
  3. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #3
    framework that most modern packages use.
    http://www.openwall.com/phpass/


    office php pages over it.
    http://www.php.net/manual/en/function.crypt.php

    Make sure the password has a number (0-9), Symbol's, and at least 8 char's long. That the user does not hand out the password and that your mysql calls are secure too.

    function md5crypt($password){
    
        $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.'abcdefghijklmnopqrstuvwxyz0123456789+/';
        $salt='$1$';
        for($i=0; $i<9; $i++){
            $salt.=$base64_alphabet[rand(0,63)];
        }
    
        return crypt($password,$salt.'$');
    }
    PHP:
    function md5crypt($password)
    {
       $salt = substr(str_replace('+', '.', base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(), mt_rand()))), 0, 22);
       return crypt($password,$salt.'$');
    }
    PHP:
     
    Last edited: Aug 9, 2011
    exodus, Aug 9, 2011 IP
  4. elixiusx

    elixiusx Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #4
    You can use something like MD5(SHA1(MD5($password)))...

    Some people have MD5 Crackers, some people have SHA1 crackers but if you use the both together you can get good results...
     
    elixiusx, Aug 10, 2011 IP
  5. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #5
    try this one...
    
    
    function encrypt($pw)
    {
       $salt = sha1(strtotime('now'));
       $epw = md5($salt . md5($pw));
    
       return $epw;
    }
    
    
    PHP:
     
    JohnnySchultz, Aug 10, 2011 IP
  6. xkaser101

    xkaser101 Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Very helpful thank you for everyone who cared to post i think there is another which calls for mysql's function AES_ENCRYPT and AES_DECRYPT it is secure and it can be DECRYPTED easily.
     
    xkaser101, Aug 10, 2011 IP
  7. ausrixy

    ausrixy Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #7
    most md5 and sha1 decryptors can only decrypt what users have already submitted to their database.
     
    ausrixy, Aug 10, 2011 IP
  8. ZeroGamma

    ZeroGamma Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You shouldn't encrypt your users' passwords in the traditional way, you should hash them. Hashing, via MD5, SHAx or SHAxxx hashes are one way and thus not reversible or 'decryptable'.
     
    ZeroGamma, Aug 11, 2011 IP
  9. xkaser101

    xkaser101 Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Are you sure they are safe ? i normally hash in SHA1 plus somebody suggested mixing hashes is this a good idea ? like md5(SHA1($var)); ?
     
    xkaser101, Aug 11, 2011 IP
  10. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #10
    So, why do you want to be able to decrypt the passwords? It adds a certain danger, and has got no additional value at all.

    If I were you, I would just hash the passwords, with both md5, and sha1. It is the safest.
     
    ssmm987, Aug 12, 2011 IP
  11. shamittomar

    shamittomar Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    The best way is to use one way hashing algorithms because nobody (not even you) can ever decrypt them. Some of one way hashing algos are: SHA-1, MD5, etc. And PHP has built in functions like md5(), sha1() for using them.
     
    shamittomar, Aug 12, 2011 IP
  12. lumpy

    lumpy Well-Known Member

    Messages:
    942
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    160
    #12
    LoL? The best way is of course to create your own encryption functions. This way you'll be the only one who can decrypt the code.
     
    lumpy, Aug 12, 2011 IP
  13. freelanceinphp

    freelanceinphp Member

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #13
    the best way to encrypt your user password is add some salted string in user's password string, build a logic to add salt in user's password.
    ex. user password is "iamgreatcoder" then add special character after fourth character of the string, add some number in starting of the string etc... so, your string looks like "007iamg!@#reatcoder"

    After adding a salted string apply md5
     
    freelanceinphp, Aug 12, 2011 IP
  14. wsoulrc

    wsoulrc Member

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #14
    i used

    md5(sha1(md5(sha1(md5(sha1(md5(sha1(md5(sha1(md5(sha1($var))))))))))));

    :D
     
    wsoulrc, Aug 12, 2011 IP
  15. jaydeee

    jaydeee Greenhorn

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #15
    double md5, double encryption.
    nice idea.
     
    jaydeee, Aug 13, 2011 IP