xor

XOR on a very big file

I would like to XOR a very big file (~50 Go). More precisely, I would like to do so by XORing each block of 32 bytes of a plaintext file (because of lack of memory) with the key 3847611839 and create (block after block) a new cipher file. Thank You for any help!! ...

128-bit type error

Hi, Thanks to pbos help and its program (published here, for xoring a big file), I performed some tests and I see that I have another problem: having changed the mask by another one of 128-bit, there is no default type as big as needed. I think a solution can be to include a library to increase available integer types... but rather tha...

Difference between ^ Operator in JS and Python

I need to port some JS code which involves Math.random()*2147483648)^(new Date).getTime(). While it looks like for smaller numbers, the python function and the JS function are equivalent in function, but with large numbers like this, the values end up entirely different. Python: 2147483647^1257628307380 =1257075044427 Javascr...

Recursive binary to decimal function without pow() or loops

I am doing a C course. I need to do a recursive XOR binary but I have some limitations. I can't use loop or any math.h functions, nor can I call another function from the XOR function. This is the function prototype: int binaryXor(int firstnumber[], int secondnumber[], int length); where firstnumber and secondnumber are arrays with t...

Returning a decyphered string as part of tuple in Haskell

Hi For project euler 59, I came up with this to return a list of tuples containing the decyphered string and the key used (and yes I know about Data.Bits): module XOR where import Data.List import Data.Char decToBin :: Integer -> [Integer] decToBin x = reverse $ decToBin' x where decToBin' 0 = [] decToBin' y = let (a...

word alignment of 4 byte for XOR operations

Is there any advantage in doing bitwise operations on word boundaries? Any CPU or memory optimization in doing so? Actual problem: I am trying to create XOR of two structure. Lets say structure-1 and structure-2 both of same size 10000 bytes. I leave first few hundreds bytes as it is and then start XOR of 1 and 2. Lets say I start with...

Why does the xor operator on two bytes produce an int?

//key & hash are both byte[] int leftPos = 0, rightPos = 31; while(leftPos < 16) { //possible loss of precision. required: byte, found: int key[leftPos] = hash[leftPos] ^ hash[rightPos]; leftPos++; rightPos--; } Why would a bitwise operation on two bytes in...

Why does "x ^= true" produce false in this example?

Hi, Why does the statement z ^= true produce a false when the previous produces a true ? bool v = true; bool z = false; z ^= v; Console.WriteLine(z); z ^= true; Console.WriteLine(z); OUTPUT ====== True False ...

What is XOR Encryption?

I have heard about people starting encryption and thought it may be someething I would like so I checked XOR and can't make any sense of it. So can someone tell me what XOR is ? ...

how images can be XOR using c#'s builtin methods?

how can i XOR images with bmp extension using c# built in methods or any other image processing technique: i m now doing this. but i want much more efficient method. using System; using System.Drawing; using System.Drawing.Imaging; namespace IProcessing { /// <summary> /// Summary description for LogicalOperator. /// </summary> public...

Implementing XOR in a simple image encryption method.

So with the help of you guys I finished creating my very simple image encrypter. It's enough to keep any non-tech person out, right? :P Now to the next step. Someone suggested I use XOR. I read about XOR and it's basically a logical table that determines what the answer is between two bits, right? Only when one is true, the statement i...

Simple Python Challenge: Fastest Bitwise XOR on Data Buffers

Challenge: Perform a bitwise XOR on two equal sized buffers. The buffers will be required to be the python str type since this is traditionally the type for data buffers in python. Return the resultant value as a str. Do this as fast as possible. The inputs are two 1 megabyte (2**20 byte) strings. The challenge is to substantially bea...

What is the most effective way to erase individual bits in a bitset? is it XOR or AND/NOT?

I have a large bitset that I want to frequently reset individual bits in it. Which method is faster? a) bitset[word_index] ^= 1 << bit_index or b) bitset[word_index] &= ~(1 << bit_index) The application is for the desktop (if that plays a role). ...

How could this Java routine be converted into Delphi?

I need to convert this code into Delphi. But it's too complicated to handle... Thanks... String key = xorString("STACKOVERFLOWCOM", "ASDFQWERTYKMLYDR"); String xorString(String txt, String xor) { StringBuffer str = new StringBuffer(); for( int i = 0; i < txt.length(); i++ ) { int ch = txt.charAt(i) ^ xor.charAt(i); char di...

SQL - XOR based on referencing table

Hi. Say for example, I have the following two tables: TableA { _id } TableB { _id, TableA_id, OptionString } Each row in TableA has one or more rows in TableB referencing it (using the TableA_id foreign key). My query lists rows in TableA to display to the user. OptionString can be one of two values - let's say "Option1" and "Optio...

Overloading GetHashCode and the equality operator using the XOR operator on enums

I have the following class which is part of a statictical analysis package. The MetricKey object is used as a dictionary key. Decision, MetricUnit & Portfolio are all enums. I had to override the equality operator (==) to get dictionary key matching working. I used the guidance at http://msdn.microsoft.com/en-us/library/ms173147.aspx...

XOR reversibility operation question

Hi, I have heard somewhere that using XOR is not reversible (they spoke about encryption) but I do not understand how it was meant? AFAIK even with OR operation you cannot find out which of the two bits was 1. Please, could anyone who knows how it was meant explain it to me? Thank you ...

Why are XOR often used in java hashCode() but another bitwise operators are used rarely?

I often see code like int hashCode(){ return a^b; } Why XOR? ...

Is there anyway to implement XOR in javascript

I'm trying to implement XOR in javascript in the following way: // XOR validation if ((isEmptyString(firstStr) && !isEmptyString(secondStr)) || (!isEmptyString(firstStr) && isEmptyString(secondStr)) { alert(SOME_VALIDATION_MSG); return; } Is there a better way to do this in javascript? Thanks. ...

XOR using mathematical operators

How can I implement XOR using basic mathematical operators like +,-,*,/ Update: Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp_Solve library doesn't support XOR operation. Also, it accepts only linear equations. ...