# Where can I learn basic cryptography to know more about passwords and Bitcoin?

Basically my knowledge in passwords consist of setting up a Diceware master password back then, and I know hashes are not convertible back to the original password.

Some basic question I want to know the answer for is how can a password be predicted from the hash? Like it can be known how many characters long it is exactly or at least roughly?

A newbie friendly crypto guide would be helpful. The beginner's guide was an issue on the Bitcoin S. E. board as well.

-

– Beanow Mar 20 at 18:36

## 2 Answers

A good hash doesn't give you any information about password length or anything else. The only attack against such a hash is guessing the password, and then using the hash to verify if it was correct.

Depending on the hashing scheme, the cost per guess can vary widely. For example with plain MD5 a single graphics card can try several billion guesses per second. That's why we use slow schemes, like scrypt, bcrypt or PBKDF2.

-

A good hash.   But i guess most sites use a bad one, like 95% of them, right? And from a bad hash can you guess about the length?  Ps.   End a line with two spaces to add a <br/> linebreak:  This doesn't work all the time. – superuser Jan 7 at 15:23
@superuser In this respect pretty much any hash used in practice is good(even MD5). Only really bad homebrew hashes would be vulnerable to that. Using fast hashes or not salting are the two common issues. | PS. you can't use line breaks in comments, only in questions and answers. – CodesInChaos Jan 7 at 15:29

At the core of your question is a concept called entropy, which is the amount of uncertainty or unpredictability in a set of data.

In cryptography, entropy is related to probabilities, expressed in terms of powers of 2 (bits.) For example, a fair coin flip has one bit of entropy: it can be either heads (1) or tails (0). Flipping four coins gives you four bits. Rolling one six sided die gives you 2.6 bits of entropy, and so on. Ultimately, the number of bits of entropy represents the number of tries required to test every possible input (also known as a brute force attack.)

Be careful not to confuse a password with a hash of a password. A SHA-1 hash is 160 bits of data that looks very random, but isn't. If I were to tell my computer to guess every possible value for a SHA-1 hash ( $2^{160}$ ), it would take longer than forever. But that doesn't mean the hash value has 160 bits of entropy. If I know the hash value is the result of running a user's password through a SHA-1 algorithm, as an attacker I don't have to try all $2^{160}$ possible values. I just have to figure out all the values you might have chosen for a password, and run them through the hash algorithm myself.

Because users are humans, the passwords they choose are frequently based in their native language. If you're guessing the password of an English speaker, it's common to start with a list of frequently chosen passwords, such as "god", "admin", "root", "password", "abc123", etc, and then move on to testing all the rest of the words in an English dictionary. If a dictionary has 200,000 words in it, the entropy is only 18 bits, and it takes only a second or two for a computer to test all 200,000 possible dictionary words.

Note that password restrictions reduce the number of words I would have to test. If a password policy says "passwords must be 6 letters long", then I would first test all six letter dictionary words, which is faster than testing all 200,000 dictionary words. One thing we assume in all cryptosystems is that the attacker knows everything about the system in use, just not the values of the secrets involved.

Check out the wiki page I linked above for a fairly readable introduction to the concepts of entropy.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 2, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9432998895645142, "perplexity_flag": "middle"}