8

I'm working on an elevator project just for fun, it's actually hardware. But I think this is more of a software question. I don't need to have this feature, in fact it is completely redundant, but I was curious so I'm adding it anyway so I can learn :P

I have an 8 bit address, 8 bit data bus, and an 8 bit encryption code. I have a master and many slave devices. The master knows the address of the slaves and knows the encryption code. The slaves know their address and the encryption code as well.

I want a really simple algorithm such that:

The master sends "y" where, y = function(data,encryption code) The slave receives "y" and can extract data by data = function2(y,encryption code)

I tried playing around with AND, XOR, OR, etc... and combinations of them, but couldn't figure it out.

Again I'm looking for simple algorithms. If you don't mind you could do me a bigger favour and explain some theory on how I can come to such a solution/functions.

Thanks so much!

3
  • Simple and effective encryption is going to come in the form of a library, not something you write yourself. Merely simple encryption could be ROT13. Commented Apr 25, 2013 at 15:48
  • XTEA is relatively simple, RC4 as well, but it's a bit hard to use correctly. Commented Apr 25, 2013 at 15:50
  • 1
    A very simple approach - send y = x XOR key, then x = y XOR key on the other side, but there won't be much protection there. Commented Apr 25, 2013 at 15:51

1 Answer 1

20

You can use XOR cipher it's very simple:

E(x,key)=> y= x XOR key
D(y,key)=> x= y XOR key

very simple!

You can upgrade the encryption and to make it to cipher-block chaining that means for example you have a data D you need to divide it to blocks, let say block of size B. for the first block you do:

E(b0,key)=> y0= b0 XOR key

the result its going to be the key for the next block encryption:

E(b1,y0)=> y1= b0 XOR y0 .... E(bn,yn-1)=> yn= bn XOR yn-1

enter image description here

The original data was D={b0,b1.....bn} and the encrypted data its now E={y0,y1....yn} to decrypt the encrypted data you need to do the opposite way! that's all!

Sign up to request clarification or add additional context in comments.

1 Comment

CBC is a mode of operation for block ciphers. What you're describing is neither CBC nor encryption. You only need the key to decrypt y0, all other blocks are merely obfuscated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.