首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

数组异或有关问题

2012-02-25 
数组异或问题DimFileData()asbyteDimFileNameasStringFilename C:\1.ogg RedimFileData(FileLen(Filena

数组异或问题
Dim   FileData()   as   byte
Dim   FileName   as   String
Filename= "C:\1.ogg "
Redim   FileData(FileLen(Filename))
Open   FileName   for   binary   as   #1
Get   #1,1,Filedata
Close   #1

然后需要把Filedata当中每4个节和字符串abcd异或,如果文件大小不为4的倍数,则最后剩余的不足4字节的部分不进行加密...
T_T   怎么写代码?

[解决办法]
上面发错了
Dim FileData() as byte
Dim FileName as String
Filename= "C:\1.ogg "
Redim FileData(Filelen(filename)-1) as byte
Open FileName for binary as #1
Get #1,1,Filedata
Close #1
dim i as integer
dim lenmax as integer
lenmax = Filelen(filename)
if lenmax mod 4 <> 0 then
lenmax = lenmax - (lenmax mod 4)
end if

for i = 0 to lenmax step 4
Filedata(i) = Filedata(i) and 65
Filedata(i+1) = Filedata(i+1) and 66
Filedata(i+2) = Filedata(i+2) and 67
Filedata(i+3) = Filedata(i+3) and 68
next

热点排行