MCPcopy Index your code
hub / github.com/RustPython/RustPython / _init_old

Method _init_old

Lib/hmac.py:108–140  ·  view source on GitHub ↗
(self, key, msg, digestmod)

Source from the content-addressed store, hash-verified

106 self.block_size = self._hmac.block_size
107
108 def _init_old(self, key, msg, digestmod):
109 import warnings
110
111 digest_cons = _get_digest_constructor(digestmod)
112
113 self._hmac = None
114 self._outer = digest_cons()
115 self._inner = digest_cons()
116 self.digest_size = self._inner.digest_size
117
118 if hasattr(self._inner, 'block_size'):
119 blocksize = self._inner.block_size
120 if blocksize < 16:
121 warnings.warn(f"block_size of {blocksize} seems too small; "
122 f"using our default of {self.blocksize}.",
123 RuntimeWarning, 2)
124 blocksize = self.blocksize # pragma: no cover
125 else:
126 warnings.warn("No block_size attribute on given digest object; "
127 f"Assuming {self.blocksize}.",
128 RuntimeWarning, 2)
129 blocksize = self.blocksize # pragma: no cover
130
131 if len(key) > blocksize:
132 key = digest_cons(key).digest()
133
134 self.block_size = blocksize
135
136 key = key.ljust(blocksize, b'\0')
137 self._outer.update(key.translate(trans_5C))
138 self._inner.update(key.translate(trans_36))
139 if msg is not None:
140 self.update(msg)
141
142 @property
143 def name(self):

Callers 4

__initMethod · 0.95
test_attributesMethod · 0.80
test_realcopyMethod · 0.80

Calls 8

updateMethod · 0.95
_get_digest_constructorFunction · 0.85
hasattrFunction · 0.85
lenFunction · 0.85
warnMethod · 0.45
digestMethod · 0.45
ljustMethod · 0.45
translateMethod · 0.45

Tested by 3

test_attributesMethod · 0.64
test_realcopyMethod · 0.64