指点一下传输过程中的数据加密解密方法

vick 2011-03-18 04:02:55
因为某些数据需要通过客户外部网络传输,所以涉及到数据在传输过程中需要加密解密。

传输过程包括一些图像数据(10-50K之间),回传数据很小,最多1-2K。

现在要求是这样:

1、数据在加密后不能过多增加数据量,比如数据加密前为10K,加密后的数据不能比10K大太多,最多增加30%以内。

2、加密解密过程不能有过多开销,比如执行加密解密函数,所需要花费的时间不能超过1秒。

有好的算法或现成的函数,SDK这些,可以高分相送!
...全文
270 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
steel1985 2011-03-18
  • 打赏
  • 举报
回复
RSA,DES都能做加密,而且效率也还可以
steel1985 2011-03-18
  • 打赏
  • 举报
回复
RSA,DES都能做加密,而且效率也还可以
  • 打赏
  • 举报
回复
DES加密:

private static void EncryptData(String inName, String outName, byte[] desKey, byte[] desIV)
{
//Create the file streams to handle the input and output files.
FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);
FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);
fout.SetLength(0);

//Create variables to help with read and write.
byte[] bin = new byte[100]; //This is intermediate storage for the encryption.
long rdlen = 0; //This is the total number of bytes written.
long totlen = fin.Length; //This is the total length of the input file.
int len; //This is the number of bytes to be written at a time.

DES des = new DESCryptoServiceProvider();
CryptoStream encStream = new CryptoStream(fout, des.CreateEncryptor(desKey, desIV), CryptoStreamMode.Write);

Console.WriteLine("Encrypting...");

//Read from the input file, then encrypt and write to the output file.
while(rdlen < totlen)
{
len = fin.Read(bin, 0, 100);
encStream.Write(bin, 0, len);
rdlen = rdlen + len;
Console.WriteLine("{0} bytes processed", rdlen);
}

encStream.Close();
fout.Close();
fin.Close();
}

摘自MSDN
yalan 2011-03-18
  • 打赏
  • 举报
回复
要求这么低,确实基本所有的加密都能用,给你推荐几个:
http://www.blogjava.net/heyang/archive/2010/12/26/341556.html

walkghost 2011-03-18
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 vrhero 的回复:]

引用楼主 vick 的回复:
10-50K之间

最多增加30%以内

所需要花费的时间不能超过1秒

你这要求太低了,所有商用加密算法都满足...自己挑去吧...

System.Security.Cryptography 命名空间
[/Quote]
UP。这位大神,好清闲啊~~~
xsi640 2011-03-18
  • 打赏
  • 举报
回复
加密算法
http://www.dotnetdev.cn/2011/03/%E4%B8%80%E7%A7%8D%E7%AE%80%E5%8D%95%E7%9A%84%E5%AF%B9%E7%A7%B0%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95/
压缩算法
http://www.dotnetdev.cn/2011/03/gzip%E5%92%8Cdeflate%E4%B8%A4%E7%A7%8D%E6%95%B0%E6%8D%AE%E5%8E%8B%E7%BC%A9%E7%AE%97%E6%B3%95/
vrhero 2011-03-18
  • 打赏
  • 举报
回复
[Quote=引用楼主 vick 的回复:]
10-50K之间

最多增加30%以内

所需要花费的时间不能超过1秒
[/Quote]
你这要求太低了,所有商用加密算法都满足...自己挑去吧...

System.Security.Cryptography 命名空间
xsi640 2011-03-18
  • 打赏
  • 举报
回复
可以先加密,再压缩...50k内的数据来看,时间不会超过1s
对称加密算法,压缩算法网上google吧

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧