MCPcopy Create free account
hub / github.com/demoth/jake2 / engineDigest

Method engineDigest

qcommon/src/main/java/jake2/qcommon/MD4.java:161–187  ·  view source on GitHub ↗

Completes the hash computation by performing final operations such as padding. At the return of this engineDigest, the MD engine is reset. @return the array of bytes for the resulting hash value.

()

Source from the content-addressed store, hash-verified

159 * @return the array of bytes for the resulting hash value.
160 */
161 public byte[] engineDigest() {
162 // pad output to 56 mod 64; as RFC1320 puts it: congruent to 448 mod 512
163 int bufferNdx = (int) (count % BLOCK_LENGTH);
164 int padLen = (bufferNdx < 56) ? (56 - bufferNdx) : (120 - bufferNdx);
165
166 // padding is alwas binary 1 followed by binary 0s
167 byte[] tail = new byte[padLen + 8];
168 tail[0] = (byte) 0x80;
169
170 // append length before final transform:
171 // save number of bits, casting the long to an array of 8 bytes
172 // save low-order byte first.
173 for (int i = 0; i < 8; i++)
174 tail[padLen + i] = (byte) ((count * 8) >>> (8 * i));
175
176 engineUpdate(tail, 0, tail.length);
177
178 byte[] result = new byte[16];
179 // cast this MD4's context (array of 4 ints) into an array of 16 bytes.
180 for (int i = 0; i < 4; i++)
181 for (int j = 0; j < 4; j++)
182 result[i * 4 + j] = (byte) (context[i] >>> (8 * j));
183
184 // reset the engine
185 engineReset();
186 return result;
187 }
188
189 // own methods
190 //...........................................................................

Callers 2

testMethod · 0.95
Com_BlockChecksumMethod · 0.95

Calls 2

engineUpdateMethod · 0.95
engineResetMethod · 0.95

Tested by 1

testMethod · 0.76