资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

流扩展:StreamExtensions-创新互联

10年积累的做网站、成都网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有回民免费网站建设让你可以放心的选择与我们合作。>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security.Cryptography; using System.IO; namespace Beehive.CloudReader.Utility { /// /// Stream 扩展 /// public static class StreamExtensions { /// /// /// /// /// /// /// public static System.IO.Stream Encrypt(this System.IO.Stream stream, byte[] key) where Algorithm : SymmetricAlgorithm { var alg = Activator.CreateInstance(); PasswordDeriveBytes pdb= new PasswordDeriveBytes(key, null); alg.Key= pdb.GetBytes(alg.KeySize / 8); alg.GenerateIV(); alg.IV= pdb.GetBytes(alg.IV.Length); ICryptoTransform encryptor= alg.CreateEncryptor(); return new CryptoStream(stream, encryptor, CryptoStreamMode.Read); } /// /// /// /// /// /// /// public static System.IO.Stream Decrypt(this System.IO.Stream stream, byte[] key) where Algorithm : SymmetricAlgorithm { var alg = Activator.CreateInstance(); PasswordDeriveBytes pdb= new PasswordDeriveBytes(key, null); alg.Key= pdb.GetBytes(alg.KeySize / 8); alg.GenerateIV(); alg.IV= pdb.GetBytes(alg.IV.Length); ICryptoTransform encryptor= alg.CreateDecryptor(); return new CryptoStream(stream, encryptor, CryptoStreamMode.Read); } /// /// /// /// /// public static byte[] ToByteArray(this System.IO.Stream stream) { byte[] buffer = new byte[1000]; int readLength = 1; using (MemoryStream ms = new MemoryStream()) { while (readLength > 0) { readLength= stream.Read(buffer, 0, buffer.Length); if (readLength > 0) ms.Write(buffer,0, readLength); } return ms.ToArray(); } } } }
文章题目:流扩展:StreamExtensions-创新互联
URL标题:http://www.cdkjz.cn/article/esogg.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220