kermit10000000 / Cyphers

Code for all kind of cyphers to encrypt and decrypt messages
Mozilla Public License 2.0
0 stars 0 forks source link

XOR #9

Closed kermit10000000 closed 7 years ago

kermit10000000 commented 7 years ago

latin alphabet is 26 letters when XOR encryption can give us result 0-31 so what should we do in case when we exceed 26. Should we just accept it?

kermit10000000 commented 7 years ago

Solved. If we want use XOR cypher only on letters the alphabet letter number must be multiplicity of the number 2 (like 16 or 32) and the key must be less than the alphabet length. Only then we will avoid situation when the XOR operation outcome will exceed the length of the alphabet and there will be no matching letter like in ASCII. Example of the missing letter in ASCII: R (17 - 10001) XOR 12(01100) we will get 11101(29) and latin alphabet used in ASCII has only 26 letters(0-25). Although since that solution requireing more letters would be pointless in ASCII as it would not be ASCII anymore my second solution is to simply swap every sign not matter whether it is letter or other sign. The minus of this solution is that if we exceed 127 we will get ascii letters for extended ASCII(usually seen in console as "?" in the box sign .