Simple Encryption Algorithm

I'm working on an elevator project just for fun, it's actually hardware. But I think this is more of a software issue. I do not need to have this function, in fact it is completely redundant, but I was curious, so I add it anyway so that I can find out: P

I have an 8-bit address, an 8-bit data bus, and an 8-bit encryption code. I have a master and many slaves. The master knows the address of subordinates and knows the encryption code. Slaves also know their address and encryption code.

I need a really simple algorithm that:

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

I tried to play with AND, XOR, OR, etc. and their combinations, but could not understand.

Again I am looking for simple algorithms. If you don't mind, you can do me a great service and explain some theory about how I can come to such a solution / functions.

Thank you very much!

+6
source share
1 answer

You can use the XOR cipher , it is very simple:

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

very simple!

You can update the encryption and make it a chain of encryption chains , which means, for example, that you have data D, you need to divide it into blocks, let it be a block of size B. for the first block:

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

The result will be key to the following block encryption:

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

enter image description here

The initial data was D={b0,b1.....bn} , and the encrypted data is now E={y0,y1....yn} to decrypt the encrypted data, you need to do the return trip! all this!

+16
source

Source: https://habr.com/ru/post/943633/


All Articles