# Caesar Cipher - logic circuit [closed]

my teacher asked the class to do a digial circuit that encrypted a message using cesar's cipher, and a circuit to decrypt, but my only idea is to solve it using a circuit that does P + K mod N, where P is The position of the letter in the alphabet, K the value of the key, and N is the number of letters in the alphabet. Or use an adder circuit, for example, when P and K have 4 bits, and N equals 8. Even if an overflow occurs, the sum between them would still give me a result within my representation. However, in my case I am using an alphabet with 94 symbols, so how can I solve this problem?

I appreciate any help.

• This is essentially "how do I write this program?" question, except with digital circuits rather than a programming language. Sorry, but this kind of question is off-topic. I'm not sure if it would be on-topic at Electrical Engineering (which covers electronics, too) -- check their help centre. – David Richerby Jul 11 '17 at 11:55

You can instead subtract $N-K$ and test if you go negative and then add $N$ again. Or test the number against $N/2$ and if greater subtract $N-K$ otherwise add $K$.
With 94 symbols you only need 7 bits. If you go with the post check you'll need to add a bit to account for overflows for certain values of input and $K$.