How to make a program of this in c++ | Sololearn: Learn to code for FREE!

How to make a program of this in c++

In cryptography, encryption is the process of transforming information using an algorithm called cipher to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key. Let us implement an encryption program using paired cipher algorithm. A paired cipher algorithm uses two letters encrypted together. In the following formulae P1 and P2 are the numeric values of a pair of letters, while C1 and C2 represent the encrypted letters. C1= (1xP1 + 3xP2) mod 26 + 1 C2= (2xP1 + 7xP2) mod 26 + 1 So the first letter A becomes, C1= (1x1 + 3x2) mod 26 +1 = 8 which is letter H. And the second letter B is encrypted as, C2= (2x1 + 7x2) mod 26 + 1 = 17 which is letter Q. Thus the two letters AB are encrypted as HQ. If the original letters were YZ, then C1 = (1x25 + 3x26) mod 26 + 1 = 26 => Z and C2 = (2x25 + 7x26) mod 26 + 1 = 25 => Y Thus YZ is encrypted as ZY. Where two letters span a space, then the two letters should be converted and output with the space output in the same position as in the input. This method only works in an even number of alphabetic characters. OUTPUT Example Original Message: QUICK BROWN FOX JUMPS OVER THE LAZY DOG Encrypted Message: CZSNR KLLNO ZNC OIDVJ DCHG SSP QBCL AKB

13th Nov 2018, 4:49 PM
1 Respuesta
+ 2
Interesting! or maybe you have solved this behind the scenes? would like to try this, but a few questions first if you don't mind. * Since we'll be processing the string in 2 characters chunks what happens if the substring length is odd, what to do with the last character. e.g. "AN ANT", or "THIS ONE". The string length is even, but one of them is a space, the second word length isn't fully divisible by 2. * Should we take into account the character case, any different treatment between lower and upper case characters? T.I.A
20th Nov 2018, 5:09 PM