MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / SHA256

Class SHA256

hashes/sha256.py:23–194  ·  view source on GitHub ↗

Class to contain the entire pipeline for SHA1 Hashing Algorithm >>> SHA256(b'Python').hash '18885f27b5af9012df19e496460f9294d5ab76128824c6f993787004f6d9a7db' >>> SHA256(b'hello world').hash 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'

Source from the content-addressed store, hash-verified

21
22
23class SHA256:
24 """
25 Class to contain the entire pipeline for SHA1 Hashing Algorithm
26
27 >>> SHA256(b'Python').hash
28 '18885f27b5af9012df19e496460f9294d5ab76128824c6f993787004f6d9a7db'
29
30 >>> SHA256(b'hello world').hash
31 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'
32 """
33
34 def __init__(self, data: bytes) -> None:
35 self.data = data
36
37 # Initialize hash values
38 self.hashes = [
39 0x6A09E667,
40 0xBB67AE85,
41 0x3C6EF372,
42 0xA54FF53A,
43 0x510E527F,
44 0x9B05688C,
45 0x1F83D9AB,
46 0x5BE0CD19,
47 ]
48
49 # Initialize round constants
50 self.round_constants = [
51 0x428A2F98,
52 0x71374491,
53 0xB5C0FBCF,
54 0xE9B5DBA5,
55 0x3956C25B,
56 0x59F111F1,
57 0x923F82A4,
58 0xAB1C5ED5,
59 0xD807AA98,
60 0x12835B01,
61 0x243185BE,
62 0x550C7DC3,
63 0x72BE5D74,
64 0x80DEB1FE,
65 0x9BDC06A7,
66 0xC19BF174,
67 0xE49B69C1,
68 0xEFBE4786,
69 0x0FC19DC6,
70 0x240CA1CC,
71 0x2DE92C6F,
72 0x4A7484AA,
73 0x5CB0A9DC,
74 0x76F988DA,
75 0x983E5152,
76 0xA831C66D,
77 0xB00327C8,
78 0xBF597FC7,
79 0xC6E00BF3,
80 0xD5A79147,

Callers 2

test_match_hashesMethod · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_match_hashesMethod · 0.68