Android Question How to implement a XOR between array of bytes

prbmjr

Active Member
Licensed User
Hi everyone,

I must implement a XOR operation between arrays of bytes, because I need to implement a special data encryption requeted by my client..

I found only the bit.xor function between integers, Is there a way to implement a XOR with arrays?

Thank you in advance!

br,

Paulo Bueno
 

prbmjr

Active Member
Licensed User

Hi Erel,

Thank you very much for your answer. I had something like this already implemented, but my concern is about the performance, if I have to use this type of code instead a real function/library using big arrays, like 500k, 50mb, etc... These arrays are entires files that must be encrypted... I have a similar code in python for reference and this runs really fast using the function numpy.bitwise_xor . I will try and I let you know with the result.

br,

Paulo Bueno
 
Upvote 0

prbmjr

Active Member
Licensed User

Hi Erel,

I tested with this code:

B4X:
Sub ArrayXor_teste As Byte()
    'assuming that the arrays are with the same length
    Dim b1(552643), b2(552643) As Byte
    Dim b3(b1.Length) As Byte

    For i = 0 To b1.Length - 1
        
        b3(i) = Bit.Xor(b1(i), b2(i))
    Next
    Return b3
End Sub

In my test I used a Sansung S8 device and takes 32 seg, why??
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…