xor

C++ xor all data in packet

I need a small program that can calculate the checksum from a user input. Unfortunately, all I know about the checksum is that it's xor all data in packet. I have tried to search the net for an example without any luck. I know if I have a string: 41,4D,02,41,21,04,02,02,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00...

A or B, not both, not neither

Ever since reading Clean Code I have been trying to keep my code descriptive and easy to understand. I have a condition where either A or B must be filled in. But not both. And not neither. Currently the if statement to check for this condition is hard to follow at a glance. How would you write the following to make it clear at a gl...

xor definition (this sentence is to make the title acceptable)

Possible Duplicate: What does ^ do in c# (Enums)? This may be a noobish question but...nowhere have I seen what Xor means in c++ or c#. I think it might mean and/or and if it does, im smart cause that's a blind guess =D. I use c# now but im pretty sure xor means the same thing. The problem is - I don't know what xor means. ...

Does J have a built-in bitwise xor primitive?

I know J has a primitive that works like xor ~:, but this is really a not equal to (!=) I can make it function like a bitwise xor by saying:xor =: 4 : '#.((#:x)~:(#:y))' within a verb definition, but this only works when the binary representations of the numbers are the same length. Is there anything I can do short of making a full-out ...

Maximum execution time exceeded (PHP)

hey all, im getting this error, and i don't know why. Fatal error: Maximum execution time of 30 seconds exceeded in E:\web\autoopti\thanks.php on line 65 The code I have for the PHP script is: <?php $key = 129; $email = $_REQUEST["payer_email"]; $first = $_REQUEST["first_name"]; $last = $_REQUEST["last_name"]; $...

Simple XOR (PHP & C#)

hey all, is it possible to have some sort of very simple reversible encryption in php that can be reversed using C# Winforms? thank you ...

binary file encryption problem

hello all. i'm having a problem while encrypting some data in the file. i'm using simple xor for that. lets say i have this struct: struct MyFile{ char fileName[128]; int account; float balance;}; saving this as a binary file is working properly but when i use xor to encrypt the filename in the struct and save the struct to hd then re...

XOR of three values

What is the simplest way to do a three-way exclusive OR? In other words, I have three values, and I want a statement that evaluates to true IFF only one of the three values is true. So far, this is what I've come up with: ((a ^ b) && (a ^ c) && !(b && c)) || ((b ^ a) && (b ^ c) && !(a && c)) || ((c ^ a) && (c ^ b) && !(a && b)) Is th...

Code Golf: XOR Encryption

From: Encryption Co. To: x$*sj4 (that's you) Your mission, should you choose to accept it, is to create a program in the shortest number of keystrokes that Takes two filenames parameters (either command line or stdin), the first is a file containing the key and the second some message. Both files will be plain text. Applies the key t...

C code for XOR linked list

I have been trying to Implement XOR linked list and its operations but I have not been able to do it properly. Is it possible to implement it in C since XOR link list involves operations on addresses?? I would be very thankful if some actual working code is given. ...

Contents of string change when exiting loop

I have a simple function, that checks if the strings given match a certain condition, then generate a 3rd string based on the 2 ones received as arguments. The 3rd string is fine but when I return it it suddenly turn into "\n". string sReturn = ""; if (sText.size() != sPassword.size()) { //Checks to see if the texts match a conditi...

How to find original values back from the final result output of the sequential Xor procedures?

The problem is that I want to get the original values of B, or the original value of C or A. Here is the code: Dim strA As String = "A" Dim strB As String = "B" Dim strC As String = "C" Dim result As Byte = 0 ' Fetch the byte character code of strings and Xor them all into the result in a sequence. result = resu...

xor encryption: setting value of key to 904932 eating up 'd'

i am making a program to implement xor encryption,while playing around with my program i entered various key combinations the program was working perfectly until i entered value of key : 904932 which caused ommition of 'd' character e.g if i enter 'hi my name is dexter and i hate my stupid sister dede' in edit1,encrypting and decrypting...

How to make an Encode function based on this Decode function?

How to make an Encode function based on this Decode function? I got the source code for the Decode function on the internet but I need the Encode function. All my attempts to make it failed and the original coder isn't available at the moment. The (original) code: byte Decode(byte EncodedByte) { EncodedByte ^= (byte)194; Encod...

OTP/XOR Cracking two ciphertexts that have the same key

How can I crack two ciphertexts that have used the same key twice? For example, plaintext1 uses the key "abcdefg", and plaintext2 uses the key "abcdefg". I know that ciphertext2 ^ ciphertext1 is equal to plaintext1 ^ plaintext2. And the method to crack plaintext1 ^ plaintext2 is the same method to crack a "book cipher" (also sometimes c...

Any cool XOR tricks?

Looking forward to see some cool XOR tricks. May be using other bit-wise operators also. ...

XOR Encryption in Java: losing data after decryption

Hi, I'm currently writing a very small Java program to implement a one-time-pad, where the pad (or key) itself is generated as a series of bytes using a SecureRandom object, which is seeded using a simple string with the SHA-512 algorithm. Generating the one-time-pad hasn't caused any problems, and if I supply the same seed string each...

Why swap with xor works fine in c++ but in java doesn't ? some puzzle

Possible Duplicate: Why is this statement not working in java x ^= y ^= x ^= y; Sample code int a=3; int b=4; a^=(b^=(a^=b)); In c++ it swaps variables, but in java we get a=0, b=4 why? ...