{"id":4441,"date":"2014-04-10T11:30:02","date_gmt":"2014-04-10T15:30:02","guid":{"rendered":"https:\/\/www.kaspersky.co.za\/blog\/?p=4441"},"modified":"2020-12-15T20:15:36","modified_gmt":"2020-12-15T18:15:36","slug":"the-wonders-of-hashing","status":"publish","type":"post","link":"https:\/\/www.kaspersky.co.za\/blog\/the-wonders-of-hashing\/4441\/","title":{"rendered":"The Wonders of Hashing"},"content":{"rendered":"<p>A cryptographic hash function \u2013 often referred to simply as a hash \u2013 is a mathematical algorithm that transforms any arbitrary block of data into a string of new characters of a fixed length. Regardless of the length of the input data, the same type of hash will always output a hash value of the same length.<\/p>\n<p>So, according to an online, SHA-1 hash generator (SHA-1 is one of the most widely deployed hash functions in computing, along with MD 5 and SHA-2), the hash for my name, Brian, is: 75c450c3f963befb912ee79f0b63e563652780f0. As probably any other Brian can tell you, \u2018brain\u2019 is an incredibly common misspelling of the name. So common in fact, I once had an official driver\u2019s license on which my name was spelled, \u201cBrain Donohue,\u201d but that\u2019s another story. The SHA-1 hash for brain, again according to my online SHA-1 generator, is: 8b9248a4e0b64bbccf82e7723a3734279bf9bbc4.<\/p>\n<p>As you can see, those two outputs are quite different, despite the fact that the difference between the name Brian and the word for the organ at the center of your central nervous system depends entirely on the arrangement of two consecutive vowels (\u2018ia\u2019 versus \u2018ai\u2019). To push this point even further, if I input my name without capitalizing the first letter, the SHA-1 generator again returns a vastly different hashed result: 760e7dab2836853c63805033e514668301fa9c47.<\/p>\n<div class=\"pullquote\">Cryptographic hash functions are a ubiquitous tool in computing, used for everything from identity verification to malware detection to file protection.<\/div>\n<p>You\u2019ll notice that all the hashes here are 40 characters long, which is unsurprising given that in each case the input is five characters long. However, more surprisingly, entering every word of this story so far into the hash generator returns the following hash: db8471259c92193d6072c51ce61dacfdda0ac3d7. That\u2019s some 1,637 characters (with spaces included) condensed down \u2013 just like the five-character words above \u2013 into a 40 character output. You could SHA-1 hash the collected works of William Shakespeare and still end up with a 40-character output. Furthermore, no two inputs yield the same hashed output.<\/p>\n<p>Here\u2019s a picture courtesy of Wikimedia Commons illustrating the same concept for those of you who prefer visual learning:<\/p>\n<p><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/103\/2014\/04\/06043858\/Cryptographic-Hashing-Explained.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4443\" alt=\"Cryptographic Hashing Explained\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/103\/2014\/04\/06043858\/Cryptographic-Hashing-Explained.png\" width=\"680\" height=\"455\"><\/a><\/p>\n<p><b>What are hashes used for?<\/b><\/p>\n<p>Great question. Unfortunately, the answer is that crypto hashes are used for a whole lot of things.<\/p>\n<p>For me and you, the most common form of hashing has to do with <a href=\"https:\/\/www.kaspersky.co.za\/blog\/21st-century-passwords\/\" target=\"_blank\" rel=\"noopener\">passwords<\/a>. For example, if you ever forget your password to some online service, you will likely have to perform a password reset. When you reset your password, you generally don\u2019t receive your plaintext password in return. That\u2019s because the online service doesn\u2019t store your plaintext password. They store a hash value for that password. In fact, that service (unless you are using an incredibly simple password for which the hash value is widely recognized) has no idea what your real password is.<\/p>\n<p>To be clear, if you do receive your plaintext password in return, that means that the online service you are using isn\u2019t hashing your password and shame on them.<\/p>\n<p>You can test this yourself with an online reverse hash generator. If you generate a hash value for <a href=\"https:\/\/threatpost.com\/password-is-no-longer-the-worst-password\/103746\" target=\"_blank\" rel=\"noopener nofollow\">a weak password<\/a> like \u201cpassword\u201d or \u201c123456\u201d and then enter that hash value into a reverse hash generator, chances are the reverse hash generator will recognize the hash value for either of those passwords. In my case, the reverse hash generator recognized the hashes for \u2018brain\u2019 and \u2018Brian\u2019 but not the hash that represents the body of this text. So the integrity of a hash output is entirely dependent on the input data, which can be literally anything.<\/p>\n<p>On that point, <a href=\"http:\/\/techcrunch.com\/2014\/03\/30\/how-dropbox-knows-when-youre-sharing-copyrighted-stuff-without-actually-looking-at-your-stuff\/\" target=\"_blank\" rel=\"noopener nofollow\">according to a report from TechCrunch late last month<\/a>, the popular cloud storage service, Dropbox, blocked one of its users from sharing content protected under the Digital Millennium Copyright Act (DMCA). This user tweeted that he had been blocked from sharing certain content, and Twitter blew up a bit with people shouting and screaming about how Dropbox must be rifling through user content despite promising not to do exactly that in its <a href=\"https:\/\/threatpost.com\/dropbox-addresses-government-surveillance-with-updated-privacy-policy\/104423\" target=\"_blank\" rel=\"noopener nofollow\">privacy policy<\/a>.<\/p>\n<p>Dropbox, of course, did not rifle through any user content. As noted by the TechCrunch article, what likely happened here is that the copyright holder took their copyrighted file (perhaps the digital makeup of a song or movie) and passed it through a hash function. They then took the output hash value and added that series of forty characters to some sort of denylist for the hashes of copyright-protected materials. When the user tried to share this copyright-protected material, Dropbox\u2019s automated scanners picked up on the denied hash and blocked it from being shared.<\/p>\n<p>So, you can clearly hash passwords and media files, but what other purposes do cryptographic hash functions serve? Again, the true answer is that hash functions serve more purposes than I know, understand, or care to write about. However, there is one more hashing application that is close to our hearts here at the Kaspersky Daily. Hashing is widely deployed in the practice of malware detection by Antivirus firms like <a href=\"http:\/\/www.kaspersky.com\" target=\"_blank\" rel=\"noopener nofollow\">Kaspersky Lab<\/a>.<\/p>\n<p>Sort of in the same way that movie studios and record labels create hash denylists to protect copyrighted data, there are any number of malware hash value denylists as well, most of which are publicly available. These malware hash \u2013 or malware signature \u2013 denylists consist of the hash values of malware or the hash values of smaller and recognizable components of malware. On the one hand, if a user finds a suspicious file, that user can enter its hash value into one the many publicly available malware hash registries or databases, which will inform the user as to whether the file is malicious or not. On the other hand, one way antivirus engines recognize and ultimately block malware is by comparing file hashes to their own (and also public) malware signature repositories.<\/p>\n<p>Cryptographic hash functions are also used to ensure something called message integrity. In other words, you can ensure that some communication or a file has not been tampered with by examining a hash output generated both before and after the data transmission. If the before and after hashes are identical, then the transmission is said to be authentic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cryptographic hash functions are a ubiquitous tool in computing, used for everything from identity verification to malware detection to file protection.<\/p>\n","protected":false},"author":42,"featured_media":4442,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5,9],"tags":[1251,599,592,597,598,261,594,36,595,596,593],"class_list":{"0":"post-4441","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-news","8":"category-tips","9":"tag-antivirus","10":"tag-certificate","11":"tag-crypto","12":"tag-cryptography","13":"tag-digital-signature","14":"tag-encryption","15":"tag-hash","16":"tag-malware-2","17":"tag-math","18":"tag-sha-1","19":"tag-signature"},"hreflang":[{"hreflang":"en-za","url":"https:\/\/www.kaspersky.co.za\/blog\/the-wonders-of-hashing\/4441\/"},{"hreflang":"en-in","url":"https:\/\/www.kaspersky.co.in\/blog\/the-wonders-of-hashing\/3300\/"},{"hreflang":"en-ae","url":"https:\/\/me-en.kaspersky.com\/blog\/the-wonders-of-hashing\/3180\/"},{"hreflang":"en-us","url":"https:\/\/usa.kaspersky.com\/blog\/the-wonders-of-hashing\/3595\/"},{"hreflang":"en-gb","url":"https:\/\/www.kaspersky.co.uk\/blog\/the-wonders-of-hashing\/3629\/"},{"hreflang":"ru","url":"https:\/\/www.kaspersky.ru\/blog\/the-wonders-of-hashing\/3633\/"},{"hreflang":"x-default","url":"https:\/\/www.kaspersky.com\/blog\/the-wonders-of-hashing\/4441\/"},{"hreflang":"ja","url":"https:\/\/blog.kaspersky.co.jp\/the-wonders-of-hashing\/3279\/"},{"hreflang":"ru-kz","url":"https:\/\/blog.kaspersky.kz\/the-wonders-of-hashing\/3633\/"},{"hreflang":"en-au","url":"https:\/\/www.kaspersky.com.au\/blog\/the-wonders-of-hashing\/4441\/"}],"acf":[],"banners":"","maintag":{"url":"https:\/\/www.kaspersky.co.za\/blog\/tag\/antivirus\/","name":"Antivirus"},"_links":{"self":[{"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/posts\/4441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/comments?post=4441"}],"version-history":[{"count":5,"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/posts\/4441\/revisions"}],"predecessor-version":[{"id":28392,"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/posts\/4441\/revisions\/28392"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/media\/4442"}],"wp:attachment":[{"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/media?parent=4441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/categories?post=4441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kaspersky.co.za\/blog\/wp-json\/wp\/v2\/tags?post=4441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}