In your case, breaking a hash algorithm is equivalent to detecting a collision in a hash algorithm. This means that you do not need to search for the password itself (which would be a preimage attack ), you just need to find the hash output of the function equal to the hash of the real password (thus, βcollisionβ). A collision search using a birthday attack takes O (2 ^ n / 2), where n is the length of the output of the hash function in bits.
SHA-2 has an output size of 512 bits, so O (2 ^ 256) will be required to find a collision. Given that there are no smart attacks on the algorithm itself (currently, none of them are known for the SHA-2 hash family), this is what it takes to break the algorithm.
To understand what 2 ^ 256 actually means: it is currently estimated that the number of atoms in the (whole !!!) universe is about 10 ^ 80, which is about 2 ^ 266. Assuming an input of 32 bytes (which reasonable for your case - 20 bytes of salt + 12 bytes), my machine takes ~ 0.22 s (~ 2 ^ -2 s) for 65536 (= 2 ^ 16) calculations. Thus, 2 ^ 256 calculations would be performed in calculations 2 ^ 240 * 2 ^ 16, which would take
2^240 * 2^-2 = 2^238 ~ 10^72s ~ 3,17 * 10^64 years
Even calling these millions of years is ridiculous. And it's not much better with fast hardware on the planet that computes thousands of hashes in parallel. No human technology can crunch this number into something acceptable.
So forget about the coarse coercion of SHA-256. Your next question was about vocabulary words. Rainbow tables have traditionally been used to extract such weak passwords. The rainbow table, as a rule, is a table of pre-computed hash values, the idea is that if you were able to recompute and save all possible hashes along with your input, then you need O (1) to find the given hash and get a valid prototype for him. Of course, this is impossible in practice, since there is no storage device that could store such a huge amount of data. This dilemma is known as memory-time compilation . Since you can store so many values ββthat regular rainbow tables include some form of hash chain with intermediate reduction functions (this is explained in detail in the Wikipedia article) in order to save space by refusing to save time.
Salts were a countermeasure to make such rainbow tables impracticable. To prevent cybercriminals from pre-calculating the table for a particular salt, it is recommended that you apply salt values ββfor each user. However, since users do not use secure, completely random passwords, it is still amazing how successful you can get if the salt is known, and you simply iterate over a large dictionary of shared passwords in a simple trial and error scheme. The connection between natural language and chance is expressed as
entropy . Typical password choices usually have low entropy, while completely random values ββwill contain a maximum of entropy.
The low entropy of typical passwords provides a relatively high probability that one of your users will use a password from a relatively small database of shared passwords. If you are Google for them, you will eventually find torrent links for such password databases, often in the gigabyte size category. The success of such a tool is usually from a few minutes to several days, if the attacker is not limited in any way.
Therefore, as a rule, hashing and salting are not enough, you also need to install other security mechanisms. You must use an artificially slowed-down entropy method such as PBKDF2, described in PKCS # 5 , and you must ensure that the waiting period for this user is respected before they can re-enter the password. A good scheme is to start at 0.5 s and then double that time for each failed attempt. In most cases, users do not notice this and do not fail much more often than three times on average. But this will significantly slow down any malicious outsider trying to attack your application.