我应该在散列之前对数据进行编码以避免Invalid length for a Base-64 char array
.
# 我的 .cs :
Stream des = file.InputStream;
byte[] data = new byte[file.ContentLength];
des.Read(data, 0, file.ContentLength);
FileStream f = new FileStream(targetFileName, FileMode.Create, FileAccess.ReadWrite);
f.Write(data, 0, data.Length);
f.Flush();
f.Close();
///////////////////////////////////////////////////////////////////////////////////////////
var sha = new System.Security.Cryptography.SHA512Managed();
string hash2 = Convert.ToBase64String(sha.ComputeHash(data));
如果答案是肯定的,如何编码字节数组。
笔记:
我使用散列来唯一标识上传的文件以进行任何更改。