Python/hashes
Tianyi Zheng 33114f0272
Revamp md5.py (#8065)
* Add type hints to md5.py

* Rename some vars to snake case

* Specify functions imported from math

* Rename vars and functions to be more descriptive

* Make tests from test function into doctests

* Clarify more var names

* Refactor some MD5 code into preprocess function

* Simplify loop indices in get_block_words

* Add more detailed comments, docs, and doctests

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Add type hints to md5.py

* Rename some vars to snake case

* Specify functions imported from math

* Rename vars and functions to be more descriptive

* Make tests from test function into doctests

* Clarify more var names

* Refactor some MD5 code into preprocess function

* Simplify loop indices in get_block_words

* Add more detailed comments, docs, and doctests

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Convert str types to bytes

* Add tests comparing md5_me to hashlib's md5

* Replace line-break backslashes with parentheses

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-04-01 22:05:01 +02:00
..
__init__.py Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
adler32.py refactor: Move constants outside of variable scope (#7262) 2022-10-16 15:03:29 +05:30
chaos_machine.py Add flake8 pluin flake8 bugbear to pre-commit (#7132) 2022-10-13 18:03:06 +02:00
djb2.py Add flake8-builtins to pre-commit and fix errors (#7105) 2022-10-13 19:53:59 +05:30
elf.py Added Builtin Voltage (#7850) 2022-10-30 12:52:20 +01:00
enigma_machine.py Add Flake8 comprehensions to pre-commit (#7235) 2022-10-15 19:29:42 +02:00
hamming_code.py Make some ruff fixes (#8154) 2023-03-01 17:23:33 +01:00
luhn.py Pyupgrade to Python 3.9 (#4718) 2021-09-07 13:37:03 +02:00
md5.py Revamp md5.py (#8065) 2023-04-01 22:05:01 +02:00
README.md Added Readme file to document the hashing algorithm. (#6743) 2022-10-30 11:50:08 +01:00
sdbm.py Add flake8-builtins to pre-commit and fix errors (#7105) 2022-10-13 19:53:59 +05:30
sha1.py New gitter link added or replaced (#8551) 2023-03-26 17:19:18 +02:00
sha256.py Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062) 2022-10-13 00:54:20 +02:00

Hashes

Hashing is the process of mapping any amount of data to a specified size using an algorithm. This is known as a hash value (or, if you're feeling fancy, a hash code, hash sums, or even a hash digest). Hashing is a one-way function, whereas encryption is a two-way function. While it is functionally conceivable to reverse-hash stuff, the required computing power makes it impractical. Hashing is a one-way street. Unlike encryption, which is intended to protect data in transit, hashing is intended to authenticate that a file or piece of data has not been altered—that it is authentic. In other words, it functions as a checksum.

Common hashing algorithms

MD5

This is one of the first algorithms that has gained widespread acceptance. MD5 is hashing algorithm made by Ray Rivest that is known to suffer vulnerabilities. It was created in 1992 as the successor to MD4. Currently MD6 is in the works, but as of 2009 Rivest had removed it from NIST consideration for SHA-3.

SHA

SHA stands for Security Hashing Algorithm and its probably best known as the hashing algorithm used in most SSL/TLS cipher suites. A cipher suite is a collection of ciphers and algorithms that are used for SSL/TLS connections. SHA handles the hashing aspects. SHA-1, as we mentioned earlier, is now deprecated. SHA-2 is now mandatory. SHA-2 is sometimes known has SHA-256, though variants with longer bit lengths are also available.

SHA256

SHA 256 is a member of the SHA 2 algorithm family, under which SHA stands for Secure Hash Algorithm. It was a collaborative effort between both the NSA and NIST to implement a successor to the SHA 1 family, which was beginning to lose potency against brute force attacks. It was published in 2001. The importance of the 256 in the name refers to the final hash digest value, i.e. the hash value will remain 256 bits regardless of the size of the plaintext/cleartext. Other algorithms in the SHA family are similar to SHA 256 in some ways.

Luhn

The Luhn algorithm, also renowned as the modulus 10 or mod 10 algorithm, is a straightforward checksum formula used to validate a wide range of identification numbers, including credit card numbers, IMEI numbers, and Canadian Social Insurance Numbers. A community of mathematicians developed the LUHN formula in the late 1960s. Companies offering credit cards quickly followed suit. Since the algorithm is in the public interest, anyone can use it. The algorithm is used by most credit cards and many government identification numbers as a simple method of differentiating valid figures from mistyped or otherwise incorrect numbers. It was created to guard against unintentional errors, not malicious attacks.