had a brain blip when discussing coding with a coworker

  1. 5 weeks ago

    scott b

    May 18 Pre-Release Testers, Xojo Pro local coffee shop

    Sooo it has been a long month and even longer week.

    A coworker and I was discussing "encryption" techniques and stuff at lunch. ROT13 came up. Works on string but not on anything else. But why cant we write something similar for binary? something that takes all the 1s and makes 0s and all the 0s and make 1s. It really isnt encrypted it is just obfuscated. and to decrypt it you just encrypt it for a second time. just like ROT13. And if we do it at the binary level we really dont care the file type or anything.

    as we were talking about doing it in various languages, all was great until it came to Xojo. I could not think of a good way to do it in Xojo without writing a C based plugin and calling the methods of that plugin (or dll).

    So for an educational discussion how would yall do it?

  2. Mathias M

    is not verified May 18 Pre-Release Testers Bruges, Belgium
    Edited 5 weeks ago

    Should not be to hard:

    Load the data in a Memory block, read byte per byte'. Creatie a function hat 'reverses' a byte bit by bit. Write the byte to a new Memory block. Repeat until all bytes are read and written.

    Wouldn't be very efficiënt, but should do the job.

    That's thé best idea I have being almost midnight on my phone on thé toilet.

  3. Jared F

    May 18 Pre-Release Testers, Xojo Pro Milwaukee, WI

    Would you be able to utilize http://docs.xojo.com/index.php/Bitwise.OnesComplement in some way?

  4. Michael D

    May 18 Pre-Release Testers, Xojo Pro

    http://developer.xojo.com/xor will do what you want. In fact, many real encryption algorithms work by XORing the plaintext against a pseudo random number.

    In your case, you'd just XOR each byte with &b11111111

or Sign Up to reply!