问题描述
amespaceSky.Decrypt{usingSystem;usingSystem.IO;usingSystem.Runtime.Serialization;usingSystem.Runtime.Serialization.Formatters.Binary;usingSystem.Security.Cryptography;usingSystem.Text;publicclassDecryption{privatestringtemporaryFileName=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),"license.dat");publicstringDecryptFile(stringpath,stringkey){stringstr="";if(!File.Exists(path)){thrownewException("Fileisnotexist.");}byte[]rgbIV=newbyte[]{0x12,0x34,0x56,120,0x90,0xab,0xcd,0xef};byte[]bytes=Encoding.UTF8.GetBytes(key);FileStreamstream=newFileStream(path,FileMode.Open,FileAccess.Read);longlength=stream.Length;DESdes=newDESCryptoServiceProvider();CryptoStreamstream2=newCryptoStream(stream,des.CreateDecryptor(bytes,rgbIV),CryptoStreamMode.Read);StreamReaderreader=newStreamReader(stream2);try{str=reader.ReadToEnd();}finally{stream.Close();}returnstr;}publicstringDecryptString(stringdata,stringkey){stringstr="";if((data==null)||(data=="")){thrownewException("Dataisempty.");}byte[]rgbIV=newbyte[]{0x12,0x34,0x56,120,0x90,0xab,0xcd,0xef};byte[]bytes=Encoding.UTF8.GetBytes(key);MemoryStreamstream=newMemoryStream();DESdes=newDESCryptoServiceProvider();CryptoStreamstream2=newCryptoStream(stream,des.CreateDecryptor(bytes,rgbIV),CryptoStreamMode.Write);try{byte[]buffer=Convert.FromBase64String(data);stream2.Write(buffer,0,buffer.Length);stream2.FlushFinalBlock();str=Encoding.UTF8.GetString(stream.ToArray());}finally{stream2.Close();stream.Close();}returnstr;}privatestringDeserializeFile(stringpath){stringstr="";if(!File.Exists(path)){thrownewException("Fileisnotexist.");}IFormatterformatter=newBinaryFormatter();FileStreamserializationStream=newFileStream(path,FileMode.Open,FileAccess.Read);try{str=(string)formatter.Deserialize(serializationStream);}finally{serializationStream.Close();}returnstr;}publicstringGetString(stringpath){returnthis.DeserializeFile(path);}}}
解决方案
解决方案二:
分别是解密文件、解密字符串、反序列化文件等函数你只管调用这些函数就行了,函数体内部的你不用了解
解决方案三:
那解密密码是什么呢?能知道解密的密码吗?
解决方案四:
加密用的是什么密码,解密就用什么密码解密的前提必须知道加密密码,才能解密,跟函数体代码无关
解决方案五:
现在不知道加密的密码,所以从这段代码中能看出加密的密码吗?
解决方案六:
能看出来。。。还需要加密吗?
解决方案七:
引用4楼的回复:
现在不知道加密的密码,所以从这段代码中能看出加密的密码吗?
看不出来
解决方案八:
该回复于2012-04-05 15:09:13被版主删除
解决方案九:
该回复于2012-04-05 15:41:21被版主删除
解决方案十:
该回复于2012-04-05 16:35:37被版主删除
解决方案十一:
该回复于2012-04-05 17:04:32被版主删除
解决方案十二:
能看出来。。。还需要加密吗?
解决方案十三:
建议,单步调试,结合msdn看