{"id":35,"date":"2022-02-17T18:04:40","date_gmt":"2022-02-17T18:04:40","guid":{"rendered":"https:\/\/demo.wpshuffle.com\/article-read-time\/?page_id=35"},"modified":"2022-04-24T17:34:11","modified_gmt":"2022-04-24T17:34:11","slug":"progress-bar","status":"publish","type":"page","link":"https:\/\/demo.wpshuffle.com\/article-read-time\/progress-bar\/","title":{"rendered":"Progress Bar"},"content":{"rendered":"\n<p id=\"3b60\">Before we start, try to forget everything you know about passwords. Rules like \u201cPasswords must include a capital letter and a number\u201d or those little \u201cstrength meters\u201d that give you the reassuring green checkmark that your password is impenetrable are dangerously misleading and incomplete. Some of the reasons are mathematical, but a lot of it has to do with human behavior as well. Let\u2019s take a look at the math behind the curtain, and why an understanding of human habits can defeat the most powerful algorithms.<\/p>\n\n\n\n<p id=\"f23c\">When you type your password and press enter to log in to an account, your web-browser runs code that&nbsp;<em>hashes<\/em>&nbsp;your password, converting it into a long string of seemingly random letters, numbers, and symbols- from which it is impossible to tell what the original input was. This hash is stored on the server, so each time you log in, the hashes are compared- not your plain password. This way, only you know your password- not even system administrators can see it, and if the server is breached by hackers, they will only see the garbled-looking hash.<\/p>\n\n\n\n<p id=\"8688\">The crux of this process is the&nbsp;<em>hash function&nbsp;<\/em>\u2014the specific mathematical operations that change your password into this gibberish. Hash functions can be quite complex, but the basic idea is something pretty familiar. Let\u2019s say our function is just simple addition, and our input is 2 integers as the \u2018password\u2019. You set a \u2018password\u2019 of 3 and 4. This is \u2018hashed\u2019 to 7 (3 +4 =7). Only this 7 is stored on the server. If a hacker gains access to the server and finds this \u2018hash\u2019, he has no way of knowing whether your \u2018password\u2019 is 3 and 4, or 1 and 6, or 5 and 2. This is a crucial point:&nbsp;<strong><em>you cannot conclusively determine the original input from the output.<\/em><\/strong>&nbsp;Hash functions are&nbsp;<strong>one-way.<\/strong>&nbsp;(This is different than encryption, where you can easily regain the original input). Now, this example of addition as a hash function is incomplete- if the server just knows your numbers should equal 7, then any 2 numbers that sum to 7 will work to guess your \u2018password.\u2019 This is called having many&nbsp;<em>collisions-&nbsp;<\/em>when two or more inputs result in the same hashed output. So, we need to add some transformation that results in as few collisions as possible, but still avoid any reversible operations. Let\u2019s try concatenating the original digits, and multiplying the resulting number by our sum. So for 3 and 4, we\u2019d have 3 + 4 = 7, then 7 * 34 = 238. For 5 and 2, we\u2019d have 5 + 2 = 7, then 7 * 52 = 364.<br>Remember, any guess that we make has to be in the form of 2 numbers, so we\u2019d have to calculate the entire answer for each set of 2 numbers we want to guess. So what two numbers give us the output 1305?<\/p>\n\n\n\n<p id=\"570e\">You could probably figure it out eventually with a calculator, or faster by writing a program to guess and check, but it would take some work. This is basically the idea behind modern password hashing. Modern hash functions are highly complex, and take a computer a relatively large amount of energy to calculate. So even when we know what the formula is and what the output hash is, we have to invest such a large amount of computational time to guess that it becomes prohibitive to try. As we\u2019ll explore below, it could take a computer easily thousands of years to guess a password. In fact, it\u2019s been shown that with certain hash functions, the heat-death of the universe would occur before we could calculate all possible hashes with current global computing power.<\/p>\n\n\n\n<p id=\"dd2d\">The only way to \u201ccrack\u201d a password is to calculate the hash for a given input, and see if it matches the hash you\u2019re trying to crack- i.e. guess and check. So for example, say the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/MD5\" target=\"_blank\">hash function called MD5<\/a>&nbsp;takes 3000 CPU cycles to calculate (the actual number varies by formula and computer system), and maybe it takes 10 cycles to compare and see if the hashes are the same\u2026 so 3010 cycles to check one hash. If you have a 10 character password, there\u2019s 72\u00b9\u2070 possible permutations of lowercase letters, capital letters, digits, and symbols (possibly more depending on what symbols are allow as input)- about 3.75 quintillion possibilities. So with one core of a typical 3GHz CPU and about 3000 cycles per hash, we have 3 billion cycles per second divided by 3000 cycles per hash = 1 million hashes per second. One quintillion is a thousand billion millions, so 3.75 trillion seconds to calculate all possible combinations\u2026which is about 118,833 years of constant CPU time at 1 million hashes per second. We\u2019ll come back to this in a moment.<\/p>\n\n\n\n<p id=\"4f9c\">It might help to understand exactly what happens in a hash formula, and why that takes CPU cycles. The short answer is, it\u2019s just a bunch of math operations. In a modern PC CPU, you have registers which hold 64 bit binary numbers, and the CPU can perform basic logic operations on those, like AND-ing two numbers together, or comparing them for equality. To do that, enough electricity has to be run through the transistors that make up the CPU to cause the electrons to move a \u201cstep forward\u201d through the logic gates- similar to how a certain amount of electricity is required to make an electric motor revolve one time. So, a hash formula typically involves doing enough math to require at least a few thousand of these operations.<\/p>\n\n\n\n<p id=\"02bf\">Most real hash functions are quite intensive, and guarantee unique outputs for each input, etc. But modern CPUs have many cores, and you can also leverage the cloud\u2026.so say we have a bunch of cloud servers that totals 100 cores at 3GHz- using our example above of 118,833 years of single-core CPU, that would get us down to 1188 years\u2026.say we have a giant server farm with ten-thousand cores, we can get it down to 0.1188 years (about 6 weeks). That\u2019s for every possible hash, of course- i.e. we would have cracked every single possible password. If we were just trying to find a single hash, we might get lucky and crack it in perhaps a measly couple decades.<\/p>\n\n\n\n<p id=\"6b56\">In reality, we don\u2019t need to guess&nbsp;<em>all<\/em>&nbsp;the possibilities. Most people use combinations of letters and numbers that relate to their lives- e.g. English words and numbers from their birthdate- so we can vastly reduce the amount of guesses we need to take. For example, we could feed a list of every word in the English language into the popular&nbsp;<a href=\"https:\/\/hashcat.net\/hashcat\/\" rel=\"noreferrer noopener\" target=\"_blank\">cracking program Hashcat<\/a>, and instruct it to calculate hashes for each word followed by the numbers 0 to 999. So rounding up to 200,000 words in English, plus 1000 following numbers for each one is 200,000 *1000 = 200 million possibilities, which would take 200 seconds at 1 million hashes\/second. Not too bad.<\/p>\n\n\n\n<p id=\"01b8\">Of course, most sites have \u201cstrength\u201d requirements, like \u201cyour password must include at least one number, one capital letter, and one symbol.\u201d Mathematically this is a great idea, but it doesn\u2019t take into account what people actually do, and consequently these \u201cstrength\u201d rules play right into hackers\u2019 hands. A rule like this makes it harder for people to make a password they can remember, so we tend to head straight for common patterns and sequences. Most people will just capitalize the first letter of a word, put a common number like 123, 456, or a recent year, on the end, then a symbol that is easy to reach while holding the shift key- typically an exclamation point, at-sign, pound-sign, or asterisk (Yes, the keyboard layout affects how people choose passwords- \u201casdf\u201d and \u201cqwerty\u201d are some recognizable common patterns). So in practice, these requirements actually make passwords LESS safe- sure, they prevent absolutely terrible passwords like \u201cpassword\u201d, but overall they make even complex passwords much easier to guess.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before we start, try to forget everything you know about passwords. Rules like \u201cPasswords must include a capital letter and a number\u201d or those little \u201cstrength meters\u201d that give you the reassuring green checkmark that your password is impenetrable are dangerously misleading and incomplete. Some of the reasons are mathematical, but a lot of it [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-35","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/pages\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":6,"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/pages\/35\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/pages\/35\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/demo.wpshuffle.com\/article-read-time\/wp-json\/wp\/v2\/media?parent=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}