Results 1 to 8 of 8

Thread: Xor??

  1. #1
    Guest

    Arrow

    What does Xor do, I think it has something to do with encryption, but i am not sure.

    thanks for any replies.

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Exclamation Bitwise math. Argh!

    This is bitwise exclusion.
    For example, 23 Xor 50...
    To calculate this, you convert both numbers to binary.
    23 = 010111b
    50 = 110010b

    The Xor rules are: 0 Xor 0 = 0, 1 Xor 0 = 1, 0 Xor 1 = 1, 1 Xor 1 = 0.

    010111
    110010
    ======Xor
    100101

    100101 is 37. Try the calculator, do a 23 Xor 50, and you'll get 37. It's useful with logical, too:

    True Xor True = False
    True Xor False = True
    False Xor True = True
    False Xor False = False

  3. #3
    Guest
    thank you.

    how is it used in encryption?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Dennis! You can look at my encryption samples at my page, I have my string xoring against any key.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    thanks.

  6. #6
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Xor Encryption

    I use VB6 under Windows 98, 2nd edition.

    Xor can be used for encryption using a string or binary value (Key) known to both the sender and the receiver of a message. Xor has the following properties.

    (Readable message)Xor(Key) = Unreadable garbage.
    (Unreadable garbage)Xor(Key) = Original message.

    The original message is first broken into chunks, each the same length as the Key (Pad last chunk with spaces, if necessary). Xor using Key versus each chunk. Send resulting garbage. Receiver breaks garbage into chunks. Xor using Key versus each chunk, resulting in original message.

    The code I have seen converts string data into binary or hex data prior to Xor operations, and then sends the garbage as a binary file. There might be some reason for the conversion, but I am not sure. Perhaps some languages do not allow Xor versus string data (does VB allow it?). Perhaps weird side effects can occur with a string containing binary garbage (garbage bytes could look like control data).

    I hope the above gives you a clue.
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  7. #7
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    The reason the string is converted first, is while vb uses unicode for strings. Each character is 2 bytes, and if you use the western characterset, 1 byte is empty (0). This way the key can be found easily.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Guv, don't be afraid of Binary or Hex data, it's usually a form you never get in touch with in vb as it automatically converts it to either dec or string. Also to use Xor with strings, does not apply in vb, you need to convert the strings to byte array first with strconv, as i meantioned theres a fast and good example on my homepage
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width