This cipher system is the original Vernam cipher.
(In the original Vernam cipher, the key was stored on a loop of paper tape that repeated over and over).
Like all practical encryption systems, the Vernam cipher has a secret key that it uses over and over.
ciphertext[i] = plaintext[i] bit_xor key[ i % keylength ]
This cipher can be seen as a variant of the Vigenère cipher, and has the same security.
Anyone with the secret key can decrypt a ciphertext message to recover bit-for-bit the original plaintext (no matter what the keylength is) with:
plaintext[i] = ciphertext[i] bit_xor key[ i % keylength ]
Though the cipher is easy to understand and implement, for three
centuries it resisted all attempts to break it; this earned it the
description le chiffre indéchiffrable (French for 'the indecipherable
cipher'). ...
Kasiski entirely broke the cipher and published the technique ...
In 1863 Friedrich Kasiski was the first to publish a
successful general attack on the Vigenère cipher.
-- Wikipedia: Vigenère cipher
The people at the Cipher Exchange say the Vigenère cipher can be solved by pencil and paper methods with enough ciphertext -- ciphertext 15 times the length of the key.
The same techniques can be used to break this cipher, given the same amount of ciphertext.
(Some of those techniques are mentioned at "
What is the limit of plaintext required to break the Vigenère encryption?
").
% klen
part. (Exercise: what does that part actually do?) You could've also simply tried it yourself on some test data. (In any case, I'm voting to close this question as off topic, since it's really more about basic programming rather than cryptography. It would be a better fit for Stack Overflow.) $\endgroup$