我想要做的是解密文件并将Hex保存到数组中。我现在遇到的问题是当我用十六进制值的十进制表示提取它时,我无法将其转换回来
代码:
int bits;
DecryptFile
(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
@"\Akd3\CFS.exe");
}
private void DecryptFile(string input)
{
string password = @"treeessss";
byte[] Key = Encoding.ASCII.GetBytes(password);
RijndaelManaged AES = new RijndaelManaged();
FileStream FCrypted = new FileStream(input, FileMode.Open);
CryptoStream cs = new CryptoStream(FCrypted,
AES.CreateDecryptor(Key, Key), CryptoStreamMode.Read);
int data;
while ((data = cs.ReadByte()) != -1)
if((data = cs.ReadByte()) != -1)
{
bits = bits + data;
}
关于如何提取字节或转换十进制表示的任何想法都会非常有用,谢谢
答案 0 :(得分:0)
您可以使用以下代码从byte[]
获取CryptoStream
:
byte[] result;
using (MemoryStream ms = new MemoryStream())
{
using (CryptoStream cs = new CryptoStream(ms, transform, CryptoStreamMode.Write))
{
cs.Write(inputData, 0, inputData.Length);
}
result = ms.ToArray();
}
显然cs.Write...
行可以替换为调用另一个流来复制到cs