had a brain blip when discussing coding with a coworker

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?

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 efficint, but should do the job.

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

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

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