| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 546 人关注过本帖
标题:[求助]入门问题,请大家指教
只看楼主 加入收藏
luji4
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-3-17
收藏
 问题点数:0 回复次数:0 
[求助]入门问题,请大家指教

刚学C#,这个例子是对一个字节加密, 首次运行时,realen=8,totallen=1,不明白为什么运行下面的循环while (readlen < totallen),下面语句的功能看不懂,readlen = (readlen + ((len / des.BlockSize) * des.BlockSize));Blocksizer查MSDN得知是数据块,是待加密的数据还是别的什么数据,请大虾指教。最好详细的给我讲一下这个例子。

------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace P__130
{
class Program
{
static void Main(string[] args)
{
MemoryStream memstr = new MemoryStream();
memstr.WriteByte((byte)1);
memstr.Position = 0;
FileStream desfile = new FileStream("Test1.cs",FileMode.OpenOrCreate,FileAccess.Write);
desfile.SetLength(0);
SymmetricAlgorithm des = SymmetricAlgorithm.Create();
byte[] bin = new byte[4096];
long readlen = 8;
long totallen = (long)memstr.Length;

int len;
CryptoStream encStream = new CryptoStream(desfile,des.CreateEncryptor(),CryptoStreamMode.Write);
Console.WriteLine("正在加密");
while (readlen < totallen)
{
len = memstr.Read(bin, 0, 4096);
encStream.Write(bin, 0, len);
readlen = (readlen + ((len / des.BlockSize) * des.BlockSize));

}
encStream.Close();
}
}
}

搜索更多相关主题的帖子: color readlen 入门 指教 
2006-05-24 09:53
快速回复:[求助]入门问题,请大家指教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011110 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved