Questions tagged [xor]
For questions involving exclusive-or operations (typically bitwise).
1,558
questions
0
votes
0
answers
20
views
Implement XOR Operation In Elasticsearch
Can Somebody explain to me, how i cant use xor operation in elastic search.
I use most keyword for AND, Should keyword for OR, and Not for Not operation, but my mind really stuck when i wanted to ...
0
votes
1
answer
64
views
How to reverse code this linear transformation algorithm?
I am writing a module of an encryption function.
The algorithm XOR the input with 6-bit left shift and 10-bit left shift of the input itself.
Below is the code of the linear transformation.
algorithm
...
0
votes
0
answers
20
views
Can someone explain How below code is getting executed for swapping two integers? [duplicate]
I am trying to swap values with bit manipulation.
int x = 10;
int y = 25;
x = x ^ y ^ (y = x);
0
votes
0
answers
60
views
Finding duplicate value for calculated f(x) unique values of 2**128 except 2 duplicated
I have a function that calculates the next unique value on the fly. These values are 100% unique except one. Each value is 256 bit, total values are 2128. The amount of space needed to store this many ...
0
votes
0
answers
33
views
What's the use of rate/redundancy of language in breaking XOR cipher?
There's a XOR breaking algorithm described in Applied Cryptography (Bruce Schneier) (part 1.4 Simple XOR). The first part is clear. As for the second, I can't figure out what's meant by the last ...
0
votes
0
answers
45
views
bitwise XOR in Javascript with a 64 bit integer
I am looking for a way of performing a bitwise XOR on a 64 bit integer in JavaScript.
JavaScript will cast all of its double values into signed 32-bit integers to do the bitwise operations.
I already ...
0
votes
1
answer
28
views
How do I XOR a block of bytes read from a binary file in Python?
I am reading a block of bytes from a binary file using file.read(block_size). The variable that these bytes go into is typed <class 'bytes'>.
I need to XOR each byte in the stream with single ...
0
votes
0
answers
48
views
Xor in C Problem when encrypting string that has same chars as the key
I'm trying to make an simple encryption using xor and splitting the character and key in 2 pairs.
test string:
0110 0001 = a
key:
0111 0100 0110 0101 0111 0011 0111 0100 // test
Encryption&...
1
vote
1
answer
46
views
Python XOR behavior with a mix of positive/negative number
Here is two results I get when I xor 2 integers. The sames bits, but a different sign for the second parameter of the xor.
>>> bin(0b0001 ^ -0b0010)
'-0b1'
>>> bin(0b0001 ^ 0b0010)
'...
0
votes
0
answers
25
views
How to convert expression to xor cnf formulas
I have an expression like this not((a xor b xor c) and (d xor e xor f) and (g xor h xor I)). And I want to convert to xor clauses. I trying to use sympy, but it does not have a method to do that
0
votes
0
answers
63
views
Understanding John McAfee's note about a seemingly novel, yet simple, anomaly in the XOR operation?
John McAfee (the founder of McAfee anti virus company) has two tweets (first and second) in which he shares a seemingly novel note about an anomaly in XOR operation. I understand how XOR operation ...
-2
votes
1
answer
54
views
time complexity of (A[i]^x)>(A[i]&x)
'Is it possible to further optimize the time complexity this piece of calculation "(y^x)>(y&x)" in c++?(you are allowed to change the Boolean operation into other forms, for example ...
0
votes
0
answers
30
views
Converting input with XOR 15
I'm trying to cipher input with three different type or ciphers, and I am completely stuck on XOR 15.
import string
def caesar(text, shift, alphabets):
def shift_alphabet(alphabet):
...
0
votes
0
answers
56
views
What is the intuition behind using bitwise XOR operator to swap two numbers without a temporary variable? [duplicate]
I read many answers on SO explaining the code using bitwise XOR operator to solve the above problem but none of them seems to explain how to come up with that code.
For example, the following solution ...
0
votes
1
answer
44
views
Perform XOR operation on 2 "Long" variables and display the alphanumeric result in .NET Core Console Application
I'm building a .NET Core console application in which I'm trying to perform an "XOR" operation on 2 "Long" datatype values. The result I want should be alphanumeric like "...
4
votes
0
answers
132
views
Optimized way to implement XOR between floats for huge 2D array data
I need to implement xor between floats in python for huge 2D array data (like thousand row by thousand column matrix). I use the following implementation:
import struct
def fxor(a, b):
rtrn = []
a ...
-1
votes
1
answer
65
views
Is bitwise complement of (n-1) equals to (-n)
The following code prints the two odd occuring numbers in an array:
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n],x=0;
for(int i=0;i<n;i++){
...
0
votes
0
answers
31
views
I need clarfication on S-box mixing in Kuznyechik block cipher (C code)
I'm still newbie to C and I need a clarfication on a code I saw on Github: https://github.com/veracrypt/VeraCrypt/blob/master/src/Crypto/kuznyechik.c#L2155
#define ILS(x1,x2,t1,t2) { \
t1 = IT[...
0
votes
0
answers
26
views
derive private keys that have been xored whith each other to a public key
Hello everyone
I have a pool of binary data with n elements.
k of those elements (the private keys) have been xored with each other, generating another element (a public key), which is also in the ...
1
vote
1
answer
113
views
why xorshift random number generator uses the same "amount" of SBR/SBL in all examples?
I was going through a book that explained the xorshift algorithm (I know, basic stuff). Then, while searching a little bit more on the Internet, I found that all the basic examples seem to shift the ...
0
votes
0
answers
27
views
How i can us xor encryption in matlab without getting a special character? Like $ or some unreadable □ by matlab?
Let us say i want to encrypt text says "hello world"
with key is '01011010' using XOR
I converted the text into binary using Dec2Bin function
Then reshape it in way which i can XOR it with ...
-1
votes
1
answer
65
views
Why does XOR and subtraction with the same HEX values give the same result?
For example:
7A - 20 = 5A
7A XOR 20 = 5A
Of course, this will work the same using different values. Why does this occur exactly?
-1
votes
2
answers
48
views
Missing sequence number problem solved with XOR
I'm trying to understand how the XOR operation managed to solve the problem PermMissingElem
I know one of the properties of XOR is that:
A ⊕ B = C
C ⊕ A = B
C ⊕ B = A
>>> 3 ^ 4
7
>>&...
0
votes
0
answers
70
views
Compute Quick Xor Hash in C# for OneDrive
I am trying to create a method which compute the quick xor hash of local files to compare with the quick xor hash of One Drive.
How to compute OneDrive XOrHash in C#
i have followed the link above but ...
0
votes
1
answer
65
views
JAVA Bitwise XOR modulo
I have to perform bitwise XOR on array of integers and then Return the answer modulo 998244353.
I have solved the first part but I have got stuck in 2nd part. I searched on the internet but couldn't ...
1
vote
1
answer
39
views
xoring negative number doesn't return the same value with ^ and xor()
I don't understand why these doesn't return the same values.
150 ^ -91
-205
but
from pwn import *
xor(150,-91)
b'3'
Of course, chr(-205) is invalid and different to '3'
0
votes
1
answer
94
views
XOR operation on 2 pandas DataFrames
Is there any way to remove from first DataFrame all rows which can be found in second DataFrame and add rows which are exclusive only in second DataFrame (= XOR)? Here's a twist: the first DataFrame ...
0
votes
1
answer
73
views
Swift iOS XOR with a conversion from UInt8 to Int
This is code has been driving me crazy, it's so simple but cannot get it to work. I have followed several examples and help from the forum, but the XOR is not working. The problem is when I extract ...
0
votes
1
answer
35
views
Why two bytes types cannot be xored
I need a functionality to xor all possible single bytes with a bytestream. I have that function:
def byteChallenge(text):
for i in range(0xff):
res = ([bytes([i]) ^ bytes([a]) for a in ...
-1
votes
1
answer
50
views
Why XOR function does not print out the expected hex value?
So I have the following function and I wonder why when I xor X and Y, it does not print out the hex value as expected_result? Is there anything I need to add? Am I missing something in the function?
...
0
votes
1
answer
119
views
How to Xor cipher_text and and hex value?
How do I use python to Xor cipher-text1 XOR cipher-text2 = "3c0d094c1f523808000d09" and "746865" to get this "48656c"? Thanks
It is based on this
https://crypto....
-1
votes
2
answers
124
views
Comparing two string using XOR return true but the strings are different
I'm testing some ways to identify anagrams and I found a situation that got me off guard. I found out that it's possible to do using XOR so I was testing it using the XOR operator. Here's my code:
...
3
votes
1
answer
118
views
What is an elegant solution to make multiple xor comparisons in R?
I need to filter a dataset according to multiple, mutually exclusive conditions. The xor operator seems useful for this case, but it feels a bit awkward to use in the dplyr::filter function. The other ...
1
vote
0
answers
28
views
Hex Editor - Peplink .diag files changed - Can they still be opened?
Good Morning, I have a somewhat obscure question that I'm hoping someone more knowledgeable than I can share some insight and help me push forward.
My end goal is to be able to open .diag files that ...
0
votes
2
answers
214
views
How to XOR two strings using Python? [duplicate]
If I have:
cipher_text1 = "3b101c091d53320c000910"
cipher_text2 = "071d154502010a04000419"
How do I XOR the two cipher texts using Python to get:
cipher_text1_XOR_cipher_text2 = &...
0
votes
1
answer
468
views
Find of N numbers K numbers xor equalling 0
My Problem is to find k Numbers in e.g. an Vector/Array with n Numbers, which equal calculated with xor 0. I tried already to brutforce all combinations without repetition, but with n=100 and k=10 the ...
1
vote
2
answers
69
views
How is XOR helping find the unique value?
I have a problem to writhe a function that finds the unique value from an array, i could not solve the problem but i asked someone to help, he provided the solution by using XOR(^), but could not ...
-1
votes
1
answer
41
views
Decrypt message with XOR and respond over a socket
I am attempting to complete a challenge that states:
We've noticed that the aliens are sending messages between their ships, we think they're using XOR to encrypt the messages, and we've intercepted ...
1
vote
1
answer
62
views
XOR Encryption code produces wrong results
In the code blocks given below I am supposed to obtain an output like this:
Expected ciphertext: "'\r\u0006R\u0014\u0001\u001a\u0006\bR\a\u0006\u001c\u0012\rR\u0003\u001b\vE\t\a\b\u0004\0E\f\...
0
votes
1
answer
38
views
Why does my SQL trigger that simulates an XOR not work?
I want to have a condition that either the artist or the event in an assignment is null, but it rejects an assignment even though it has an artist.
The trigger:
delimiter $$
CREATE TRIGGER ...
0
votes
0
answers
48
views
Find subset of size K with maximum xor
I have to find a subset of size K from an array A (of size n) with the xor value being the highest possible.
For example A=[1, 2, 4, 6] and N=2 gives the result [1, 6] (xor=7), but with N=3 it would ...
0
votes
0
answers
140
views
ufunc 'bitwise_xor' not supported for the input types
enimg[i,j]=img[i,j]^key[z]
TypeError: ufunc 'bitwise_xor' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
1
vote
1
answer
57
views
Shifting all element positions of an array in Python given by XOR operator
I would like to know if there is a way to move all elements of a numpy array without iterating over each entry. The shift I desire is to relabel the indices by a fixed XOR operation, in the following ...
0
votes
1
answer
228
views
how to decrypt a string that is encrypted using XOR
I have tried to encrypt a string using a XOR operator and took the output in alphabets. Now when I am trying to decrypt it I'm not getting the string again.
Encryption code:
string= "Onions"
...
3
votes
5
answers
355
views
Maximize XOR Equation
Problem statement:
Given an array of n elements and an integer k, find an integer x in
the range [0,k] such that Xor-sum(x) is maximized. Print the maximum
value of the equation.
Xor-sum(x)=(x XOR A1)...
0
votes
0
answers
122
views
bash: binary XOR one file with another
I have two files, I want to perform a byte-by-byte XOR on these and output the result.
It's trivial to do in most languages, but I'd prefer to have this as a bash script and I'm not quite sure how to ...
0
votes
1
answer
34
views
How to use python3 handle bytes?
iv = "WHpwTAkmwJY="
decoded_iv = base64.b64decode(iv) # b'XzpL\t&\xc0\x96'
If I want to calc decoded_iv[0] xor 'a' xor 'b'
, how can I write my code in python3?
1
vote
0
answers
63
views
scikit MLPClassifier couldn't fit xor problem
My teacher asked us to use the scikit mlpclassifier to solve the xor problem, and asked to use 2 hidden layers the first with 4 units and the second with 2 units, and the identity for activation and ...
0
votes
1
answer
166
views
Find a subset of maximum size n with XOR k
I have an array of size a = 10⁵ with numbers with sizes of at least 16 bytes.
Now i have to find a subsequence with the xor value equal to k.
The maximum length of this subsequence is n. (1 <= n &...
0
votes
0
answers
35
views
Why is (PARTIAL SUM) XOR (MISSING NUMBER) = Total?
I've been looking into how to use the XOR operator to solve some classic problems like finding the missing number in a sequence. I understand how XOR achieves this by cancelling out duplicates through ...