Which code segment should you insert at line 05?

You are developing a method named GetHash that will return a hash value for a file. The method
includes the following code. (Line numbers are included for reference only.)

You need to return the cryptographic hash of the bytes contained in the fileBytes variable.
Which code segment should you insert at line 05?

You are developing a method named GetHash that will return a hash value for a file. The method
includes the following code. (Line numbers are included for reference only.)

You need to return the cryptographic hash of the bytes contained in the fileBytes variable.
Which code segment should you insert at line 05?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 7

Your email address will not be published. Required fields are marked *


Developer

Developer

It is D!

Daniel

Daniel

It is not D because it calls .Hash property on a byte array and that does not exist. I would say that A is correct because the TransformBlock method must be called before the TransformFinalBlock method according to msdn
https://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.transformfinalblock(v=vs.110)

Artem

Artem

What do in A answer code:
hasher.TransformFinalBlock(fileBytes, fileBytes.Length – 1, fileBytes.Length); ?
This code does not modify the outputBuffer.