hashes.sha256 ============= .. py:module:: hashes.sha256 .. autoapi-nested-parse:: Implementation of SHA256 Hash function in a Python class and provides utilities to find hash of string or hash of text from a file. Usage: python sha256.py --string "Hello World!!" python sha256.py --file "hello_world.txt" When run without any arguments, it prints the hash of the string "Hello World!! Welcome to Cryptography" References: https://qvault.io/cryptography/how-sha-2-works-step-by-step-sha-256/ https://en.wikipedia.org/wiki/SHA-2 Classes ------- .. autoapisummary:: hashes.sha256.SHA256 hashes.sha256.SHA256HashTest Functions --------- .. autoapisummary:: hashes.sha256.main Module Contents --------------- .. py:class:: SHA256(data: bytes) Class to contain the entire pipeline for SHA1 Hashing Algorithm >>> SHA256(b'Python').hash '18885f27b5af9012df19e496460f9294d5ab76128824c6f993787004f6d9a7db' >>> SHA256(b'hello world').hash 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9' .. py:method:: final_hash() -> None .. py:method:: preprocessing(data: bytes) -> bytes :staticmethod: .. py:method:: ror(value: int, rotations: int) -> int Right rotate a given unsigned number by a certain amount of rotations .. py:attribute:: data .. py:attribute:: hashes :value: [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225] .. py:attribute:: preprocessed_data .. py:attribute:: round_constants :value: [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221,... .. py:class:: SHA256HashTest(methodName='runTest') Bases: :py:obj:`unittest.TestCase` Test class for the SHA256 class. Inherits the TestCase class from unittest .. py:method:: test_match_hashes() -> None .. py:function:: main() -> None Provides option 'string' or 'file' to take input and prints the calculated SHA-256 hash