Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / Shared / DigestComparer.cs / 1305376 / DigestComparer.cs
using System; using System.Diagnostics; using System.Collections.Generic; using System.Globalization; internal class DigestComparer : IComparer, IEqualityComparer { int IComparer .Compare(byte[] digest1, byte[] digest2) { Debug.Assert(digest1.Length == 16 && digest2.Length == 16, "Invalid digest!"); for (int index = 0; index < 16; index++) if (digest1[index] != digest2[index]) return (digest1[index] < digest2[index]) ? -1 : 1; return 0; } bool IEqualityComparer .Equals(byte[] digest1, byte[] digest2) { Debug.Assert(digest1.Length == 16 && digest2.Length == 16, "Invalid digest!"); for (int index = 0; index < 16; index++) if (digest1[index] != digest2[index]) return false; return true; } int IEqualityComparer .GetHashCode(byte[] checksumBytes) { return GetMD5DigestString(checksumBytes).GetHashCode(); } internal static string GetMD5DigestString(byte[] md5Digest) { return string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}", md5Digest[0].ToString("X2", CultureInfo.InvariantCulture), md5Digest[1].ToString("X2", CultureInfo.InvariantCulture), md5Digest[2].ToString("X2", CultureInfo.InvariantCulture), md5Digest[3].ToString("X2", CultureInfo.InvariantCulture), md5Digest[4].ToString("X2", CultureInfo.InvariantCulture), md5Digest[5].ToString("X2", CultureInfo.InvariantCulture), md5Digest[6].ToString("X2", CultureInfo.InvariantCulture), md5Digest[7].ToString("X2", CultureInfo.InvariantCulture), md5Digest[8].ToString("X2", CultureInfo.InvariantCulture), md5Digest[9].ToString("X2", CultureInfo.InvariantCulture), md5Digest[10].ToString("X2", CultureInfo.InvariantCulture), md5Digest[11].ToString("X2", CultureInfo.InvariantCulture), md5Digest[12].ToString("X2", CultureInfo.InvariantCulture), md5Digest[13].ToString("X2", CultureInfo.InvariantCulture), md5Digest[14].ToString("X2", CultureInfo.InvariantCulture), md5Digest[15].ToString("X2", CultureInfo.InvariantCulture)); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConstructorExpr.cs
- GeometryGroup.cs
- ObjectStateManager.cs
- GenericTextProperties.cs
- ReadOnlyObservableCollection.cs
- MarshalDirectiveException.cs
- ExpressionEvaluator.cs
- SortQueryOperator.cs
- UnsafeNativeMethods.cs
- EventProviderWriter.cs
- basecomparevalidator.cs
- RouteTable.cs
- ViewGenerator.cs
- AffineTransform3D.cs
- CallbackDebugElement.cs
- Confirm.cs
- RemotingException.cs
- CalloutQueueItem.cs
- ListView.cs
- SerialErrors.cs
- InternalBufferOverflowException.cs
- Semaphore.cs
- TableParaClient.cs
- ShapeTypeface.cs
- BitmapPalette.cs
- SettingsPropertyIsReadOnlyException.cs
- WebPartMovingEventArgs.cs
- X509Certificate2Collection.cs
- XslNumber.cs
- SafeCryptContextHandle.cs
- PropertyReferenceSerializer.cs
- Expander.cs
- ToolStripSettings.cs
- XmlSchemaAll.cs
- GetBrowserTokenRequest.cs
- DBSchemaRow.cs
- GenericRootAutomationPeer.cs
- XmlSchemaExporter.cs
- HandleInitializationContext.cs
- X509Utils.cs
- InputBinder.cs
- SynchronizationValidator.cs
- WebPartsPersonalizationAuthorization.cs
- ObjectMemberMapping.cs
- ObjectRef.cs
- SpecialFolderEnumConverter.cs
- DataGridViewRowConverter.cs
- XmlSchemaException.cs
- DecimalFormatter.cs
- PointLightBase.cs
- EntityViewGenerationConstants.cs
- ManagementObjectCollection.cs
- NotifyCollectionChangedEventArgs.cs
- EntityTypeEmitter.cs
- WebPartDisplayModeCollection.cs
- SpellerStatusTable.cs
- AlphabeticalEnumConverter.cs
- SmtpClient.cs
- SessionState.cs
- SafeNativeMethods.cs
- UrlMapping.cs
- DbConnectionPoolIdentity.cs
- TimeIntervalCollection.cs
- SiteMap.cs
- ZipFileInfo.cs
- NullableIntAverageAggregationOperator.cs
- DataContractSerializerOperationBehavior.cs
- FlowPanelDesigner.cs
- ContainerVisual.cs
- XmlSiteMapProvider.cs
- ContextBase.cs
- SQLDouble.cs
- AccessDataSourceView.cs
- Throw.cs
- SpoolingTask.cs
- ParagraphVisual.cs
- ConstantProjectedSlot.cs
- HitTestParameters3D.cs
- WindowsAltTab.cs
- EventInfo.cs
- WebPartsSection.cs
- ComContractElementCollection.cs
- HyperlinkAutomationPeer.cs
- SignedInfo.cs
- ToolTipAutomationPeer.cs
- EpmTargetPathSegment.cs
- IsolatedStorageFileStream.cs
- BinaryObjectWriter.cs
- WhitespaceRuleLookup.cs
- View.cs
- webeventbuffer.cs
- BitmapCacheBrush.cs
- OutputCacheModule.cs
- LayoutSettings.cs
- MLangCodePageEncoding.cs
- _OSSOCK.cs
- CommandID.cs
- PersonalizationProviderHelper.cs
- CompModHelpers.cs
- IOThreadScheduler.cs