本文整理汇总了C#中System.Security.Cryptography.MD5.TransformBlock方法的典型用法代码示例。如果您正苦于以下问题:C# MD5.TransformBlock方法的具体用法?C# MD5.TransformBlock怎么用?C# MD5.TransformBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.MD5
的用法示例。
在下文中一共展示了MD5.TransformBlock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
示例2: UpdateChecksum
void UpdateChecksum (char[] buf, int count, MD5 checksum, bool final)
{
byte[] input = Encoding.UTF8.GetBytes (buf, 0, count);
if (final)
checksum.TransformFinalBlock (input, 0, input.Length);
else
checksum.TransformBlock (input, 0, input.Length, input, 0);
input = null;
}
示例3: RFC1321_e
public void RFC1321_e (string testName, MD5 hash, byte[] input, byte[] result)
{
byte[] copy = new byte [input.Length];
for (int i=0; i < input.Length - 1; i++)
hash.TransformBlock (input, i, 1, copy, i);
byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1);
Assert.AreEqual (input [input.Length - 1], output [0], testName + ".e.1");
AssertEquals (testName + ".e.2", result, hash.Hash);
// required or next operation will still return old hash
hash.Initialize ();
}
示例4: WriteHeader
private void WriteHeader(MD5 md5, Stream stream, ChunkHeader chunkHeader)
{
var chunkHeaderBytes = chunkHeader.AsByteArray();
md5.TransformBlock(chunkHeaderBytes, 0, ChunkHeader.Size, null, 0);
stream.Write(chunkHeaderBytes, 0, ChunkHeader.Size);
}
示例5: ReadUntilWithMd5
private void ReadUntilWithMd5(long nextPos, Stream fileStream, MD5 md5)
{
long toRead = nextPos - fileStream.Position;
if (toRead < 0) throw new Exception("should not do negative reads.");
while (toRead > 0)
{
var localReadCount = Math.Min(toRead, TmpReadBuf.Length);
int read = fileStream.Read(TmpReadBuf, 0, (int)localReadCount);
md5.TransformBlock(TmpReadBuf, 0, read, null, 0);
toRead -= read;
}
}