Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:42:34+00:00 2026-06-02T11:42:34+00:00

I am not sure which algorithm crypt() uses when hashing. I looked on the

  • 0

I am not sure which algorithm crypt() uses when hashing. I looked on the PHP manual, but it just says that it uses whatever is available. But how do I know which one it uses, and if it does use one, how to tell it which one to use? I am using MAMP currently as my development environment, but I figure there must be a way to find out with a statement in PHP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:42:36+00:00Added an answer on June 2, 2026 at 11:42 am

    You specify the algorithm as part of the salt string. For example, starting with $2a$ gives you a Blowfish cypher. If the machine does not support the algorithm you are trying to use, you won’t get a meaningful result. You can attempt to find out in advance which algorithms are supported by checking some of the predefined constants, such as CRYPT_BLOWFISH, although I have noticed that the constants CRYPT_SHA256 and CRYPT_SHA512 are not always defined, at least on PHP 5.2. Starting with PHP 5.3, PHP has its own implementations of the algorithms, so it does not matter what the system has available at PHP compile time like it does in PHP 5.2 and earlier. The Suhosin patch for PHP 5.2 supposedly adds at least Blowfish, but its implementation does not seem to be compatible with the one used in PHP 5.3.

    The PHP docs for the crypt() function do provide some information on how to use the salt string to specify which algorithm to use:

    • CRYPT_STD_DES – Standard DES-based hash with a two character salt
      from the alphabet "./0-9A-Za-z". Using invalid characters in the salt
      will cause crypt() to fail.
    • CRYPT_EXT_DES – Extended DES-based
      hash. The "salt" is a 9-character string consisting of an underscore
      followed by 4 bytes of iteration count and 4 bytes of salt. These are
      encoded as printable characters, 6 bits per character, least
      significant character first. The values 0 to 63 are encoded as
      "./0-9A-Za-z". Using invalid characters in the salt will cause crypt()
      to fail.
    • CRYPT_MD5 – MD5 hashing with a twelve character salt
      starting with $1$
    • CRYPT_BLOWFISH – Blowfish hashing with a salt as
      follows: "$2a$", a two digit cost parameter, "$", and 22 digits from
      the alphabet "./0-9A-Za-z". Using characters outside of this range in
      the salt will cause crypt() to return a zero-length string. The two
      digit cost parameter is the base-2 logarithm of the iteration count
      for the underlying Blowfish-based hashing algorithmeter and must be in
      range 04-31, values outside this range will cause crypt() to fail.
    • CRYPT_SHA256 – SHA-256 hash with a sixteen character salt prefixed
      with $5$. If the salt string starts with ’rounds=$’, the numeric
      value of N is used to indicate how many times the hashing loop should
      be executed, much like the cost parameter on Blowfish. The default
      number of rounds is 5000, there is a minimum of 1000 and a maximum of
      999,999,999. Any selection of N outside this range will be truncated
      to the nearest limit.
    • CRYPT_SHA512 – SHA-512 hash with a sixteen
      character salt prefixed with $6$. If the salt string starts with
      ’rounds=$’, the numeric value of N is used to indicate how many
      times the hashing loop should be executed, much like the cost
      parameter on Blowfish. The default number of rounds is 5000, there is
      a minimum of 1000 and a maximum of 999,999,999. Any selection of N
      outside this range will be truncated to the nearest limit.

    So, to specify that you want the string "password" hashed using Blowfish with 2^10 iterations, you could use

    crypt('password', '$2a$10$XA86t7EJ0xD9OYEUbnTulT');
    

    where the string starting with XA86 is the salt.

    Finally, if you want more examples or just want something to take care of all this password compatibility business for you, take a look at phpass. It is public domain and works nicely in my experience. It will automatically use the "best" algorithm on the system unless you specify that you want a hash that is compatible with multiple systems, in which case (I think) it uses MD5.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not sure but I had heard of an algorithm which can only
I am fairly new to MVC but not sure exactly which Redirect... replaces the
I see JRE all over the place, but i can not be sure which
I have an algorithm problem that I came across at work but have not
I'm not sure which is these is appropriate for my current application. I need
I'm using Oracle SQL Developer to query an Oracle DB (not sure which version
I'm developing a webapp and I'm not sure which pattern design should I use.
I need help with LINQ syntax or methodology, not sure which. Here's my issue:
I'm new to the world of XML. I'm not sure which way to build
We are designing a Flash-based language course, and I am not sure which architecture

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.