Convert string to binary & then apply ^(xor operation) on it

:) Hi people... I want to convert a string that I will get from serial port when I enter something.That will be then stored in a variable of String type. Now I want to convert this string (my typed data from serial port) into binary and store it in a variable... this variable will have all the binary stream and on it I will apply ^(xor) operation... How to do it? Can I do xor operations on the converted binary stream?

You mention strings and Strings. They are not the same thing at all

Can you please give an example of the data that you will receive ? Will it always be the same length ?

Now I want to convert this string (my typed data from serial port) into binary

Everything you store will be binary.

Do you have a question?

Everything you store will be binary.

The character A could be saved either as 01000001 or 00001010; here, both are binary. The former one is ‘ASCII coded binary’ and the later one is ‘natural binary’.

GolamMostafa: The character A could be saved either as 01000001 or 00001010; here, both are binary. The former one is 'ASCII coded binary' and the later one is 'natural binary'.

Like I said, everything you store will be binary.

AWOL: Like I said, everything you store will be binary.

If 'binary' refers to base 2, then everything we store will be in 'bit form'; otherwise, 01000001 will be evaluated to 65 (decimal) and 00001010 will be evaluated to 10 (decimal); whereas, 01000001 and 00001010 refer to the same entity (the A). The pattern 01000001 consults the ASCII Table to get A and the pattern 00001010 applies base 2 to get A.

the pattern 00001010 applies base 2 to get A.

Doesn't 00001010 (base 2) convert to HEX (base 16) to get 0A ?

01000001 and 00001010 refer to the same entity (the A)

Aren't 01000001 and 00001010 just the bit patterns that comprise the value of the byte which is stored at some particular memory address? And what they "refer to" is determined by the data type of the variable (char, unsigned char, byte)?

Beavis4ever: Doesn't 00001010 (base 2) convert to HEX (base 16) to get 0A ? Aren't 01000001 and 00001010 just the bit patterns that comprise the value of the byte which is stored at some particular memory address? And what they "refer to" is determined by the data type of the variable (char, unsigned char, byte)?

ASCII concept comes (usually) in the context of UART Communication; where, we transmit A as 01000001 which becomes 65 (decimal) in base 2. If we have wished, we could send A as 00001010 which would become 10 (decimal) in base 2. The query is about of deciding which one of the following two sayings is more appropriate: (There is no A in the memory; it is simply an image that appears on the ASCII Monitor in response to 65; it will also appear on Binary Monitor in response of 10.)

  1. A data item is saved in memory as binary.
  2. A data item is saved in memory as bit.

AWOL:
Like I said, everything you store will be binary.

all right,then my concern now is that can I apply xor operation on this string because when I do apply its gives error saying : no match for ‘operator^’ (operand types are ‘String’ and ‘byte {aka unsigned char}’)

what I am doing is initializing following variables:

byte b=1;

x=Serial.read();

byte z=x ^ b;

How is x declared ?

How about posting a complete program that demonstrates the problem ?

I didn't know it was possible to create a Broadway production out of the simple statement "Everything you store will be binary"