File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,30 @@ def rearrange(bitString32):
10
10
return newString
11
11
12
12
def reformatHex (i ):
13
+ """[summary]
14
+ Converts the given integer into 8-digit hex number.
15
+
16
+ Arguments:
17
+ i {[int]} -- [integer]
18
+ """
19
+
13
20
hexrep = format (i ,'08x' )
14
21
thing = ""
15
22
for i in [3 ,2 ,1 ,0 ]:
16
23
thing += hexrep [2 * i :2 * i + 2 ]
17
24
return thing
18
25
19
26
def pad (bitString ):
27
+ """[summary]
28
+ Fills up the binary string to a 512 bit binary string
29
+
30
+ Arguments:
31
+ bitString {[string]} -- [binary string]
32
+
33
+ Returns:
34
+ [string] -- [binary string]
35
+ """
36
+
20
37
startLength = len (bitString )
21
38
bitString += '1'
22
39
while len (bitString ) % 512 != 448 :
@@ -26,6 +43,15 @@ def pad(bitString):
26
43
return bitString
27
44
28
45
def getBlock (bitString ):
46
+ """[summary]
47
+ Iterator:
48
+ Returns by each call a list of length 16 with the 32 bit
49
+ integer blocks.
50
+
51
+ Arguments:
52
+ bitString {[string]} -- [binary string >= 512]
53
+ """
54
+
29
55
currPos = 0
30
56
while currPos < len (bitString ):
31
57
currPart = bitString [currPos :currPos + 512 ]
@@ -34,6 +60,7 @@ def getBlock(bitString):
34
60
mySplits .append (int (rearrange (currPart [32 * i :32 * i + 32 ]),2 ))
35
61
yield mySplits
36
62
currPos += 512
63
+
37
64
def not32 (i ):
38
65
i_str = format (i ,'032b' )
39
66
new_str = ''
@@ -48,6 +75,13 @@ def leftrot32(i,s):
48
75
return (i << s ) ^ (i >> (32 - s ))
49
76
50
77
def md5me (testString ):
78
+ """[summary]
79
+ Returns a 32-bit hash code of the string 'testString'
80
+
81
+ Arguments:
82
+ testString {[string]} -- [message]
83
+ """
84
+
51
85
bs = ''
52
86
for i in testString :
53
87
bs += format (ord (i ),'08b' )
You can’t perform that action at this time.
0 commit comments