本文整理汇总了C#中System.Security.RightsManagement.CryptoProvider.BlockSize属性的典型用法代码示例。如果您正苦于以下问题:C# CryptoProvider.BlockSize属性的具体用法?C# CryptoProvider.BlockSize怎么用?C# CryptoProvider.BlockSize使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Security.RightsManagement.CryptoProvider
的用法示例。
在下文中一共展示了CryptoProvider.BlockSize属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteStatus
WriteStatus(" Binding the author's UseLicense and");
WriteStatus(" obtaining the CryptoProvider.");
using (CryptoProvider cryptoProvider =
authorsUseLicense.Bind(_secureEnv))
{
WriteStatus(" Writing encrypted content.");
using (Stream clearTextStream =
File.OpenRead(contentFile) )
{
using (Stream cryptoTextStream =
File.OpenWrite(encryptedFile))
{
// Write the length of the source content file
// as the first four bytes of the encrypted file.
cryptoTextStream.Write(
BitConverter.GetBytes(clearTextStream.Length),
0, sizeof(Int32));
// Allocate clearText buffer.
byte[] clearTextBlock =
new byte[cryptoProvider.BlockSize];
// Encrypt clearText to cryptoText block by block.
for(;;)
{ // Read clearText block.
int readCount = ReliableRead(
clearTextStream,
clearTextBlock, 0 ,
cryptoProvider.BlockSize);
// readCount of zero is end of data.
if (readCount == 0) break; // for
// Encrypt clearText to cryptoText.
byte[] cryptoTextBlock =
cryptoProvider.Encrypt(clearTextBlock);
// Write cryptoText block.
cryptoTextStream.Write(cryptoTextBlock, 0,
cryptoTextBlock.Length);
}
WriteStatus(" Closing '" + encryptedFilename + "'.");
}// end:using (Stream cryptoTextStream =
}// end:using (Stream clearTextStream =
}// end:using (CryptoProvider cryptoProvider =
WriteStatus(" Done - Content encryption complete.");