最有效的方式进行XOR字节数组在vb.net [英] Most efficient way to xor byte array in vb.net

查看:161
本文介绍了最有效的方式进行XOR字节数组在vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做在vb.net将由异或数据使用字节数组作为缓冲区读取文件,并为他们创造平等文件的应用程序...什么是异或字节数组的最有效方法是什么?我虽然字节数组convertinbg到bitarray然后运行它槽XOR运算,并把它返回一个字节数组,但是这听起来像一个非常处理昂贵的任务,我很担心,这可能会影响读取/写入速度...有没有更好的方式来做到这一点?谢谢...

I am making making an application in vb.net that will read files using a byte array as buffer, and create parity files for them by xoring the data... What would be the most efficient way of xoring a byte array? I have though of convertinbg the byte array to a bitarray and then run it trough an xor operation and turn it back to a byte array, but that sounds like a very processing expensive task, and i am worried that it might impact read/write speed... is there a better way to do this? thanks...

要避免混淆:
什么应用程序不会被读取一半的文件位置1,另一半的位置2,然后是平价(两部分XOR)来定位3 ...

To avoid confusion: What the application does is read half the file to location 1, the other half to location 2, then a parity (xor of the two parts) to location 3...

推荐答案

要异或两个字节数组只是一个for循环和的 XOR运算

To Xor two byte arrays simply use a for loop and the Xor operator.

VB.Net的异或将编译方式的 CIL 异或运算code 这应该是后来JIT编译速度非常快的x86 XOR处理器指令

VB.Net's Xor will compile to a the CIL Xor opcode which should be subsequently JIT compiled to the very fast x86 XOR processor instruction.

XOR操作的成本很可能是微不足道相比文件I / O的成本。

The cost of the Xor operation is likely to be negligible in comparison to the cost of file I/O.

这篇关于最有效的方式进行XOR字节数组在vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆