What you are talking about looks like a one-time pad. The key is the same length as the plaintext, and then does some modulo math for each individual character.
A xor B = C C xor B = A
or in other words
A xor B xor B = A
Until you use the same key B on several different inputs (for example, B must be unique every time you encrypt), then theoretically you can never restore the original A without knowing what B . If you use the same B several times, then all bets are disabled.
a comment:
You should not finish more bits than you started. xor just flushes bits, it does not have carry functionality. The completion with 6 digits is just weird ... As for the code:
$plaintext = array(digit1, digit2, digit3, digit4, digit5, digit6); $key = array(key1, key2, key3, key4, key5, key6); $ciphertext = array()
Just do it like an array for simplicity. For actual data, you should work on the basis of each byte or each word and simply sequentially in each block. You can use a key string shorter than input, but it makes reverse key development easier. Theoretically, you can use one byte to do xor'ing, but then you basically only reached the rot-13 bit level level.
source share