本文整理汇总了C#中System.Security.Cryptography.MD5类的典型用法代码示例。如果您正苦于以下问题:C# MD5类的具体用法?C# MD5怎么用?C# MD5使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MD5类属于System.Security.Cryptography命名空间,在下文中一共展示了MD5类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SynchronizingFileStream
private SynchronizingFileStream(ITransactionalStorage transactionalStorage, string fileName,
StorageStreamAccess storageStreamAccess, NameValueCollection metadata,
IndexStorage indexStorage, StorageOperationsTask operations)
: base(transactionalStorage, fileName, storageStreamAccess, metadata, indexStorage, operations)
{
md5Hasher = new MD5CryptoServiceProvider();
}
开发者ID:randacc,项目名称:ravendb,代码行数:7,代码来源:SynchronizingFileStream.cs
示例2: Program
public Program()
{
md5Hasher = MD5.Create();
InitializeComponent();
folderSelector = new FolderBrowserDialog ();
//Could help improve time from open to use? Nah.
//folderSelector.RootFolder = Environment.CurrentDirectory;
}
开发者ID:Inumedia,项目名称:DuplicateFileRemover,代码行数:8,代码来源:Program.cs
示例3: AppendData
public override void AppendData(byte[] data, int offset, int count)
{
if (_md5 == null)
{
_md5 = MD5.Create();
}
_md5.TransformBlock(data, offset, count, null, 0);
}
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:8,代码来源:IncrementalMD5.cs
示例4: HMACSSLv3Verify
public HMACSSLv3Verify(byte[] key)
{
this.HashSizeValue = 288;
this.KeyValue = (byte[]) key.Clone();
_md5 = new MD5CryptoServiceProvider();
_sha1 = new SHA1CryptoServiceProvider();
}
开发者ID:cwschroeder,项目名称:MeterTestComService,代码行数:8,代码来源:PseudoRandomFunctionSSLv3.cs
示例5: WriterWorkItem
public WriterWorkItem(FileStream stream, BinaryWriter writer, MD5 md5)
{
Stream = stream;
Writer = writer;
Buffer = new MemoryStream(2048);
BufferWriter = new BinaryWriter(Buffer);
MD5 = md5;
}
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:8,代码来源:WriterWorkItem.cs
示例6: WriterWorkItem
public WriterWorkItem(FileStream fileStream, UnmanagedMemoryStream memStream, MD5 md5)
{
_fileStream = fileStream;
_memStream = memStream;
_workingStream = (Stream)fileStream ?? memStream;
Buffer = new MemoryStream(8192);
BufferWriter = new BinaryWriter(Buffer);
MD5 = md5;
}
开发者ID:danieldeb,项目名称:EventStore,代码行数:9,代码来源:WriterWorkItem.cs
示例7: HMACMD5
/// <summary>
/// Rfc 2104.
/// </summary>
/// <param name="rgbKey"></param>
public HMACMD5 (byte[] rgbKey)
{
HashSizeValue = 128;
// Create the hash algorithms.
hash1 = MD5.Create();
hash2 = MD5.Create();
this.Key = rgbKey;
}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:13,代码来源:HMACMD5.cs
示例8: FreeHasher
/// <summary>
/// Frees an object for generating the hashes that was acquired from <see cref="GetHasher"/>,
/// adding it back to the pool for later reuse.
/// </summary>
/// <param name="hasher">The object to free.</param>
static void FreeHasher(MD5 hasher)
{
lock (_hashersSync)
{
if (log.IsDebugEnabled)
log.DebugFormat("Freeing hasher [object hash: {0}].", hasher.GetHashCode());
_hashers.Push(hasher);
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:15,代码来源:Hasher.cs
示例9: CreateMD5Checksum
public static byte[] CreateMD5Checksum(this Stream stream, bool startAtBeginning = true, MD5 md5 = null)
{
if (md5 == null)
md5 = MD5.Create();
if (startAtBeginning)
stream.Seek(0, SeekOrigin.Begin);
return md5.ComputeHash(stream);
}
开发者ID:ParkitectNexus,项目名称:ParkitectNexusClient,代码行数:10,代码来源:StreamUtility.cs
示例10: FixtureSetUp
public void FixtureSetUp ()
{
Assembly a = Assembly.GetExecutingAssembly ();
hashEvidence = new Hash (a);
md5 = MD5.Create ();
digestMd5 = hashEvidence.GenerateHash (md5);
sha1 = SHA1.Create ();
digestSha1 = hashEvidence.GenerateHash (sha1);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:HashMembershipConditionTest.cs
示例11: GetHashAndReset
public override byte[] GetHashAndReset()
{
if (_md5 == null)
{
_md5 = MD5.Create();
}
_md5.TransformFinalBlock(__emptyByteArray, 0, 0);
var hash = _md5.Hash;
_md5.Dispose();
_md5 = null;
return hash;
}
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:12,代码来源:IncrementalMD5.cs
示例12: GetMD5Hash
public static string GetMD5Hash(FileInfo fileInfo)
{
if(MD5Crypto == null)
{
MD5Crypto = MD5.Create();
}
using (FileStream fs = fileInfo.OpenRead())
{
byte[] output = MD5Crypto.ComputeHash(fs);
string hashString = Convert.ToBase64String(output);
return hashString;
}
}
开发者ID:EntropyZero,项目名称:deltaRunner,代码行数:13,代码来源:DeltaHashProvider.cs
示例13: MD5HashStream
/// <summary>
/// Initializes a new instance of the <see cref="MD5HashStream"/> class.
/// </summary>
/// <param name="stream">Stream object.</param>
/// <param name="lastTransferOffset">Offset of the transferred bytes.</param>
/// <param name="md5hashCheck">Whether need to calculate MD5Hash.</param>
public MD5HashStream(
Stream stream,
long lastTransferOffset,
bool md5hashCheck)
{
this.stream = stream;
this.md5hashOffset = lastTransferOffset;
if ((0 == this.md5hashOffset)
|| (!md5hashCheck))
{
this.finishedSeparateMd5Calculator = true;
this.succeededSeparateMd5Calculator = true;
}
else
{
this.semaphore = new SemaphoreSlim(1, 1);
}
if (md5hashCheck)
{
if (CloudStorageAccount.UseV1MD5)
{
this.md5hash = new MD5CryptoServiceProvider();
}
else
{
this.md5hash = new NativeMD5();
}
}
if ((!this.finishedSeparateMd5Calculator)
&& (!this.stream.CanRead))
{
throw new NotSupportedException(string.Format(
CultureInfo.CurrentCulture,
Resources.StreamMustSupportReadException,
"Stream"));
}
if (!this.stream.CanSeek)
{
throw new NotSupportedException(string.Format(
CultureInfo.CurrentCulture,
Resources.StreamMustSupportSeekException,
"Stream"));
}
}
开发者ID:ggais,项目名称:azure-storage-net-data-movement,代码行数:54,代码来源:MD5HashStream.cs
示例14: Ssl3DeriveBytes
//clientServer: true if random bytes should be processed as first the client bytes, then the server bytes
// false otherwise
public Ssl3DeriveBytes(byte[] secret, byte[] clientRandom, byte[] serverRandom, bool clientServer)
{
if (secret == null || clientRandom == null || serverRandom == null)
throw new ArgumentNullException();
if (clientRandom.Length != 32 || serverRandom.Length != 32)
throw new ArgumentException();
m_Disposed = false;
m_Secret = (byte[])secret.Clone();
m_Random = new byte[64];
if (clientServer) {
Array.Copy(clientRandom, 0, m_Random, 0, 32);
Array.Copy(serverRandom, 0, m_Random, 32, 32);
} else {
Array.Copy(serverRandom, 0, m_Random, 0, 32);
Array.Copy(clientRandom, 0, m_Random, 32, 32);
}
m_MD5 = new MD5CryptoServiceProvider();
m_SHA1 = new SHA1CryptoServiceProvider();
Reset();
}
开发者ID:ogazitt,项目名称:TaskStore,代码行数:22,代码来源:Ssl3DeriveBytes.cs
示例15: ContinuousHashFor
public static void ContinuousHashFor(MD5 md5, Stream s, int startPosition, long count)
{
Ensure.NotNull(md5, "md5");
Ensure.Nonnegative(count, "count");
if (s.Position != startPosition)
s.Position = startPosition;
var buffer = new byte[4096];
long toRead = count;
while (toRead > 0)
{
int read = s.Read(buffer, 0, (int)Math.Min(toRead, buffer.Length));
if (read == 0)
break;
md5.TransformBlock(buffer, 0, read, null, 0);
toRead -= read;
}
}
开发者ID:danieldeb,项目名称:EventStore,代码行数:20,代码来源:MD5Hash.cs
示例16: GridFSForwardOnlyDownloadStream
// constructors
public GridFSForwardOnlyDownloadStream(
GridFSBucket bucket,
IReadBinding binding,
GridFSFilesCollectionDocument filesCollectionDocument,
bool checkMD5)
: base(bucket, binding, filesCollectionDocument)
{
_checkMD5 = checkMD5;
if (_checkMD5)
{
_md5 = MD5.Create();
}
_lastChunkNumber = (int)((filesCollectionDocument.Length - 1) / filesCollectionDocument.ChunkSizeBytes);
_lastChunkSize = (int)(filesCollectionDocument.Length % filesCollectionDocument.ChunkSizeBytes);
if (_lastChunkSize == 0)
{
_lastChunkSize = filesCollectionDocument.ChunkSizeBytes;
}
}
开发者ID:rtfmpliz,项目名称:mongo-csharp-driver,代码行数:22,代码来源:GridFSForwardOnlyDownloadStream.cs
示例17: GridFSForwardOnlyUploadStream
// constructors
public GridFSForwardOnlyUploadStream(
GridFSBucket bucket,
IWriteBinding binding,
ObjectId id,
string filename,
BsonDocument metadata,
IEnumerable<string> aliases,
string contentType,
int chunkSizeBytes,
int batchSize)
{
_bucket = bucket;
_binding = binding;
_id = id;
_filename = filename;
_metadata = metadata; // can be null
_aliases = aliases == null ? null : aliases.ToList(); // can be null
_contentType = contentType; // can be null
_chunkSizeBytes = chunkSizeBytes;
_batchSize = batchSize;
_batch = new List<byte[]>();
_md5 = MD5.Create();
}
开发者ID:RBXSystems,项目名称:mongo-csharp-driver,代码行数:25,代码来源:GridFSForwardOnlyUploadStream.cs
示例18: ByteStore
internal ByteStore(PRStream str)
{
md5 = new MD5CryptoServiceProvider();
ByteBuffer bb = new ByteBuffer();
int level = 100;
SerObject(str, level, bb);
this.b = bb.ToByteArray();
md5 = null;
}
开发者ID:bmictech,项目名称:iTextSharp,代码行数:9,代码来源:PdfSmartCopy.cs
示例19: ReadStreamEnd
public int ReadStreamEnd()
{
int exitCode = StopChildProcess();
if (md5 != null) {
md5.TransformFinalBlock(new byte[0], 0, 0);
mMD5SumOfPcm = md5.Hash;
md5.Dispose();
md5 = null;
mMD5TmpBuffer = null;
}
mBytesPerFrame = 0;
return exitCode;
}
开发者ID:klangobjekte,项目名称:bitspersampleconv2,代码行数:16,代码来源:FlacDecodeIF.cs
示例20: ReadStreamBegin
/// <summary>
/// FLACファイルからPCMデータを取り出し開始。
/// </summary>
/// <param name="flacFilePath">読み込むファイルパス。</param>
/// <param name="skipFrames">ファイルの先頭からのスキップするフレーム数。0以外の値を指定するとMD5のチェックが行われなくなる。</param>
/// <param name="wantFrames">取得するフレーム数。</param>
/// <param name="pcmData">出てきたデコード後のPCMデータ。</param>
/// <returns>0: 成功。負: 失敗。</returns>
public int ReadStreamBegin(string flacFilePath, long skipFrames, long wantFrames, int typicalReadFrames, out PcmDataLib.PcmData pcmData_return)
{
List<FlacCuesheetTrackInfo> cti;
int rv = ReadStartCommon(ReadMode.HeadereAndData, flacFilePath, skipFrames, wantFrames, out pcmData_return, out cti);
if (rv != 0) {
StopChildProcess();
mBytesPerFrame = 0;
return rv;
}
mBytesPerFrame = pcmData_return.BitsPerFrame / 8;
if (CalcMD5 && skipFrames == 0 && wantFrames == mNumFrames) {
md5 = new MD5CryptoServiceProvider();
mMD5SumOfPcm = new byte[MD5_BYTES];
mMD5TmpBuffer = new byte[mBytesPerFrame * typicalReadFrames];
}
return 0;
}
开发者ID:klangobjekte,项目名称:bitspersampleconv2,代码行数:28,代码来源:FlacDecodeIF.cs
注:本文中的System.Security.Cryptography.MD5类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论