|
-
Jun 2nd, 2007, 03:50 AM
#1
Thread Starter
Hyperactive Member
get the XOR value
How can I get the XOR value any string
Let say this is the String
L7007F
how can I get the XOR of this...
any ideas....
 If an answer to your question has been helpful, then please, Rate it! 
-
Jun 2nd, 2007, 04:26 AM
#2
Re: get the XOR value
yes there are plenty of ideas. But to XOR something you have to have a value to XOR it with. example 5 XOR 1 = 4
its a lot easier to xor numbers, but to do a string you would break it down into individual letters (using mid) and xor the char value with whatever you want.
let's say Orwell$ contains your string you want to XOR
let's say key& is your xor value
Code:
for cl =1 to len(orwell$)
mid(orwell$, cl, 1) = chr(asc(orwell$, cl, 1) XOR key)
next cl
This code steps through the string in orwell$, converts each char to its ascii value, XORs it by key, converts it back and puts it back in.
Hope this helps. To xor a string by another string simply convert both of them and xor them together (one char at a time) The 2nd string would be the decryptor for the first one (or vice versa )
Last edited by Lord Orwell; Jun 2nd, 2007 at 04:33 AM.
Reason: typed str instead of chr-oops! and didn't use closing code tag
-
Jun 2nd, 2007, 04:48 AM
#3
Thread Starter
Hyperactive Member
Re: get the XOR value
 Originally Posted by Lord Orwell
To xor a string by another string simply convert both of them and xor them together (one char at a time) The 2nd string would be the decryptor for the first one (or vice versa  )
Hi Lord...
U mean to say suppose the String is "L7007F" then
Step 1 - take L and 7 first XOR them
Step 2- take the Result of Step 1 XOR it with the Next character in string i.e 0
Step 3 - again take the result of Step 2 and XOR it with the next character i.e 0
step 4 - again take the result of Step 3 and XOR it with the next character i.e 7
step 5 - again take the result of Step 4 and XOR it with the next character i.e F
The result that we get in the Step 5 is the XOR value of the String...
This is the way it has to be done...right....
 If an answer to your question has been helpful, then please, Rate it! 
-
Jun 2nd, 2007, 06:10 AM
#4
Re: get the XOR value
no that isn't what i said at all. You can not xor a string by itself and still be able to know what the original was. What you just described is generating a checksum.
-
Jun 2nd, 2007, 06:18 AM
#5
Thread Starter
Hyperactive Member
Re: get the XOR value
What is a checksum ..?? and y is it used...
 If an answer to your question has been helpful, then please, Rate it! 
-
Jun 2nd, 2007, 06:21 AM
#6
Thread Starter
Hyperactive Member
Re: get the XOR value
 Originally Posted by Lord Orwell
let's say Orwell$ contains your string you want to XOR
let's say key& is your xor value
can u please expalin me..
what is a key and what would the Key be in the String Orwell$
 If an answer to your question has been helpful, then please, Rate it! 
-
Jun 2nd, 2007, 06:48 AM
#7
Re: get the XOR value
 Originally Posted by Kuamr
What is a checksum ..?? and y is it used...
A checksum is just like it's called - it's a sum value that allows you to check that all the preceding digits made it in a transmission, for example, without data loss.
Let's say you have the value 123
The checksum would be 1+2+3, or 6.
So the full transmitted value would be 1236.
On the receiving end you take the 6 off - getting back to 123. You re-add those 3 digits - arriving at 6. Since the 6 matches the 6 - you know you have a good transmission.
There are many methods for checksum generation. For example, if the values when added go larger than a single digit - something like 7+8+9 (which equals 24) would have a checksum value of 4 (taking only the right most digit).
This method of checksum is used in transmitting ACH files to banks - so that the bank can verify that routing numbers and account numbers are accurate.
-
Jun 2nd, 2007, 07:59 AM
#8
Thread Starter
Hyperactive Member
Re: get the XOR value
than u very much for the Info szlamany...but as Lord Orwell said in Post#2 .what would be the Key if i 'm trying to get the XOR of the String L7007F
 If an answer to your question has been helpful, then please, Rate it! 
-
Jun 2nd, 2007, 08:06 AM
#9
Thread Starter
Hyperactive Member
Re: get the XOR value
I beleive that the Key is required only when u want to Xor with some value..
What if i want to get the XORed value of the Entire String (L7007F)...any ideas........
 If an answer to your question has been helpful, then please, Rate it! 
-
Jun 2nd, 2007, 08:42 AM
#10
Re: get the XOR value
What do you mean by the XOR value??
XOR is typically used to encrypt - see this link:
http://en.wikipedia.org/wiki/Simple_XOR_cipher
But if you want to XOR a string - each character one at a time - then you are creating a CHECKSUM - but not using addition (as I did in my example) but using XOR as the operator. You would simply loop through the string and take the ascii value of each character - XOR that with the prior value (and values) and keep going along. Not sure why you would want to do this though...
-
Jun 2nd, 2007, 01:06 PM
#11
Re: get the XOR value
it depends on how much data loss you expect.
if you want a checksum equal to a range of 0 to 255 then...
Code:
dim GeneratedChecksum as long
Orwell$ = "String to get checksum for"
for cl =1 to len(orwell$) 'a loop in this case 26 times
char$ = mid(orwell$, cl, 1)
generatedchecksum = generatedchecksum + asc(char$)
if generatedchecksum > 255 then generatedchecksum = generatedchecksum - 256
'above line keeps your value one byte long
next cl
msgbox "Checksum = " & generatedchecksum"
-
Jun 2nd, 2007, 03:52 PM
#12
Re: get the XOR value
Wouldn't you get the same checksum if you have the same string but the bytes are in a different order?
-
Jun 2nd, 2007, 03:59 PM
#13
PowerPoster
Re: get the XOR value
Digi, yeah...but that's not always an important bug when it comes to checksums...I mean, both MD5 and CRC32 have possibilities for doubles for much the same reason but there's *SO* many permutations that this rarely actually happens :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 2nd, 2007, 04:48 PM
#14
Re: get the XOR value
 Originally Posted by DigiRev
Wouldn't you get the same checksum if you have the same string but the bytes are in a different order?
So will the simple checksum of adding the digits that banks use for direct deposit transmissions...
I believe that an old mainframe backup algorithm we used to have would XOR every two 512-byte records together and create a cyclic-redundancy record that got put onto the tape as well.
I'm still not clear on whether the original poster wants an encryption algo or a checksum algo anyway...
-
Jun 2nd, 2007, 05:04 PM
#15
Re: get the XOR value
Yeah. A basic checksum like that is also good enough for stuff like sending data over TCP/IP since TCP guarantees data will arrive in the same order.
I think the OP was misinformed and thought you could just XOR a single value. I don't think he was aware you need another value to XOR it with. 
I would guess he was asking about a basic XOR encryption where you loop through the chars and XOR each letter with the letter from the key.
-
Jun 2nd, 2007, 08:58 PM
#16
Re: get the XOR value
That type of XORing is exactly how raid 5 works as well. 2 drive sectors are xored together and the result is put on the 3rd. Oddly enough the 3rd drive is not just for xoring. For some reason they rotate.
-
Jun 4th, 2007, 06:17 AM
#17
Thread Starter
Hyperactive Member
Re: get the XOR value
Thanks for the Info guys......I am not looking forward to encrypt anything using XOR...the primary reason for XOring the String is that I am actually developing a PMS interface which interacts with the PBX machine....
The Scene is :
The pms interface sends a message which would consists of a String ...
the message format is as such
Code:
STX, sa,ua,message string,ETX,BCC
STX - stands for start of text
sa- system address
ua - unit address
message string - is the string whose XOR is to be calculated
ETX - specifies the End of Text
BCC- Block Check code (longitudinal redundancy checksum)
Now the BCC contains the XORed value of the message String which it sends to the PBX.
the PBX on the Other hand receives the message and again calculates the BCC form its side..(our program has to do nothing for this ..it is already done / come preloaded to calculate the BCC)
If the BCC code from the sender (PMS) matches the BCC code calculated by the Receiver (PBX) then it means that the message is transfered sucesfully...
 If an answer to your question has been helpful, then please, Rate it! 
-
Jun 4th, 2007, 10:49 AM
#18
Re: get the XOR value
Unless you have a specification for exactly what "longitudinal redundancy checksum" means, you'll have to try different algorithms on different blocks of data until you find the right one 9the one that produces the BCC that gets sent with that block).
XORing each byte with the next is a form of lrc - so is CRC32. So is the check code used on hard drives, and it's different from the other two. There are probably at least a dozen lrc algorithms being used, and dozens more that used to be used.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|