public static byte[] BCryptFinishHash(this SafeHashHandle hHash, int cbHashSize) { byte[] hash = new byte[cbHashSize]; NTSTATUS ntStatus = Interop.BCryptFinishHash(hHash, hash, cbHashSize, 0); if (ntStatus != NTSTATUS.STATUS_SUCCESS) { throw CreateCryptographicException(ntStatus); } return(hash); }