Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • crypt() String Function in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 96
    Comment on it

    The crypt() function in PHP returns a hashed value. It uses the DES, Blowfish, or MD5 algorithms.

    It returns the first two characters of the output as salt in DES-based crypt(). As salt parameter is optional but crypt() function gives a weak password without salt.

    The following constants are set depending on the availability of given type :

    • [CRYPT_STD_DES] : Standard DES-based hash with a two character salt.
    • [CRYPT_EXT_DES] : Extended DES-based hash with a nine character salt
    • [CRYPT_MD5] : MD5 hashing with a 12 character salt
    • [CRYPT_BLOWFISH] : Blowfish hashing with a salt starting with $2a$, $2x$, or $2y$, a two digit cost parameters "$", and 22 characters from the alphabet "./0-9A-Za-z"

    Syntax

    crypt(str,salt)
    

    In the above syntax the str here specifies the string to be hashed and the salt string to base the hashing on.

    for example

    <?php
       $password = 'mypassword';
       $hash = crypt($password);
    ?>
    

    in the above code the password 'mypassword' is passed to the $hash with the use of the crypto function

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: