我已将大文件分成100,000个字节的块。当我抓住每个块并“收缩”它时,一个块出现100,002个字节!为什么? 这是我的获取代码:
While (numBytesToRead > 0)
Dim nx As Integer = fsSourceSubseq.Read(FH, numBytesRead, numBytesToRead)
If (nx = 0) Then
Exit While
End If
numBytesRead = (numBytesRead + nx)
numBytesToRead = (numBytesToRead - nx)
End While`
FileHolder = System.Text.UTF8Encoding.UTF8.GetString(FH)
fsSourceSubseq.Close()
bytWholeFileHolder = Convert.FromBase64String(FileHolder)
然后我记录每个块:
My.Computer.FileSystem.WriteAllBytes("c:\2atest\bytesFH" & Chuck & ".txt", FH, False)
My.Computer.FileSystem.WriteAllBytes("c:\2atest\bytWholeFileHolderSHRUNK" & Chuck & ".txt", bytWholeFileHolder, False)
对于我的5块,我明白了:
bytesFH1.txt = 133,336
bytesFH2.txt = 133,336
bytesFH3.txt = 133,336
bytesFH4.txt = 133,336
bytesFH5.txt = 133,336
bytWholeFileHolderSHRUNK1.txt = 100,000
bytWholeFileHolderSHRUNK2.txt = 100,000
bytWholeFileHolderSHRUNK3.txt = 100,000
bytWholeFileHolderSHRUNK4.txt = 100,000
bytWholeFileHolderSHRUNK5.txt = 100,002
每个块的内容都不同,所以除了长度之外我无法比较。
答案 0 :(得分:0)
Base64将每3个字节转换为4个字节的输出。如果源数据不能被3字节整除,则在Base64结果的末尾添加填充。
这意味着不同长度的几个字符串都可以产生相同长度的Base64结果。这也意味着给定长度的Base64结果可能会解码为最长可达两个字节的源。
发布您的实际文件以供进一步分析和解释。