<s>
In	O
cryptography	O
,	O
a	O
keystream	B-Algorithm
is	O
a	O
stream	B-Architecture
of	O
random	O
or	O
pseudorandom	B-Error_Name
characters	O
that	O
are	O
combined	O
with	O
a	O
plaintext	O
message	O
to	O
produce	O
an	O
encrypted	O
message	O
(	O
the	O
ciphertext	O
)	O
.	O
</s>
<s>
The	O
"	O
characters	O
"	O
in	O
the	O
keystream	B-Algorithm
can	O
be	O
bits	O
,	O
bytes	B-Application
,	O
numbers	O
or	O
actual	O
characters	O
like	O
A-Z	O
depending	O
on	O
the	O
usage	O
case	O
.	O
</s>
<s>
Usually	O
each	O
character	O
in	O
the	O
keystream	B-Algorithm
is	O
either	O
added	O
,	O
subtracted	O
or	O
XORed	O
with	O
a	O
character	O
in	O
the	O
plaintext	O
to	O
produce	O
the	O
ciphertext	O
,	O
using	O
modular	O
arithmetic	O
.	O
</s>
<s>
Keystreams	B-Algorithm
are	O
used	O
in	O
the	O
one-time	B-Algorithm
pad	I-Algorithm
cipher	O
and	O
in	O
most	O
stream	B-Algorithm
ciphers	I-Algorithm
.	O
</s>
<s>
Block	O
ciphers	O
can	O
also	O
be	O
used	O
to	O
produce	O
keystreams	B-Algorithm
.	O
</s>
<s>
For	O
instance	O
,	O
CTR	O
mode	O
is	O
a	O
block	B-Algorithm
mode	I-Algorithm
that	O
makes	O
a	O
block	O
cipher	O
produce	O
a	O
keystream	B-Algorithm
and	O
thus	O
turns	O
the	O
block	O
cipher	O
into	O
a	O
stream	B-Algorithm
cipher	I-Algorithm
.	O
</s>
<s>
The	O
random	O
numbers	O
in	O
the	O
keystream	B-Algorithm
then	O
have	O
to	O
be	O
at	O
least	O
between	O
0	O
and	O
25	O
.	O
</s>
<s>
To	O
encrypt	O
we	O
add	O
the	O
keystream	B-Algorithm
numbers	O
to	O
the	O
plaintext	O
.	O
</s>
<s>
And	O
to	O
decrypt	O
we	O
subtract	O
the	O
same	O
keystream	B-Algorithm
numbers	O
from	O
the	O
ciphertext	O
to	O
get	O
the	O
plaintext	O
.	O
</s>
<s>
Here	O
the	O
plaintext	O
message	O
"	O
attack	O
at	O
dawn	O
"	O
is	O
combined	O
by	O
addition	O
with	O
the	O
keystream	B-Algorithm
"	O
kjcngmlhylyu	O
"	O
and	O
produces	O
the	O
ciphertext	O
"	O
kcvniwlabluh	O
"	O
.	O
</s>
