XOR cipher - wikipedia XOR cipher This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. ( July 2009 ) In cryptography, the simple XOR cipher is a type of additive cipher, an encryption algorithm that operates according to the principles : A ⊕ ( displaystyle oplus ) 0 = A, A ⊕ ( displaystyle oplus ) A = 0, ( A ⊕ ( displaystyle oplus ) B) ⊕ ( displaystyle oplus ) C = A ⊕ ( displaystyle oplus ) ( B ⊕ ( displaystyle oplus ) C ), ( B ⊕ ( displaystyle oplus ) A ) ⊕ ( displaystyle oplus ) A = B ⊕ ( displaystyle oplus ) 0 = B, where ⊕ ( displaystyle oplus ) denotes the exclusive disjunction ( XOR ) operation. This operation is sometimes called modulus 2 addition ( or subtraction, which is identical ). With this logic, a string of text can be encrypted by applying the bitwise XOR operator to every character using a given key. To decrypt the output, merely reapplying the XOR function with the key will remove the cipher. Contents 1 Example 2 Use and security 3 Example implementation 4 See also 5 References 6 Bibliography 7 External links Example For example, the string `` Wiki '' ( 01010111 01101001 01101011 01101001 in 8 - bit ASCII ) can be encrypted with the repeating key 11110011 as follows : 01010111 01101001 01101011 01101001 ⊕ ( displaystyle oplus ) 11110011 11110011 11110011 11110011 = 10100100 10011010 10011000 10011010 And conversely, for decryption : 10100100 10011010 10011000 10011010 ⊕ ( displaystyle oplus ) 11110011 11110011 11110011 11110011 = 01010111 01101001 01101011 01101001 Use and security The XOR operator is extremely common as a component in more complex ciphers. By itself, using a constant repeating key, a simple XOR cipher can trivially be broken using frequency analysis. If the content of any message can be guessed or otherwise known then the key can be revealed. Its primary merit is that it is simple to implement, and that the XOR operation is computationally inexpensive. A simple repeating XOR ( i.e. using the same key for xor operation on the whole data ) cipher is therefore sometimes used for hiding information in cases where no particular security is required. If the key is random and is at least as long as the message, the XOR cipher is much more secure than when there is key repetition within a message. When the keystream is generated by a pseudo-random number generator, the result is a stream cipher. With a key that is truly random, the result is a one - time pad, which is unbreakable even in theory. In any of these ciphers, the XOR operator is vulnerable to a known - plaintext attack, since plaintext ⊕ ( displaystyle oplus ) ciphertext = key. It is also trivial to flip arbitrary bits in the decrypted plaintext by manipulating the ciphertext. This is called malleability. Example implementation Example using the Python programming language. from __future__ import print_function, unicode_literals from os import urandom def genkey ( length ) : `` '' `` Generate key '' `` '' return urandom ( length ) def xor_strings ( s, t ) : `` '' `` xor two strings together '' `` '' if isinstance ( s, str ) : # Text strings contain single characters return `` ''. join ( chr ( ord ( a ) ^ ord ( b ) ) for a, b in zip ( s, t ) ) else : # Python 3 bytes objects contain integer values in the range 0 - 255 return bytes ( ( a ^ b for a, b in zip ( s, t ) ) ) message = ' This is a secret message ' print ( ' message : ', message ) key = genkey ( len ( message ) ) print ( ' key : ', key ) cipherText = xor_strings ( message. encode ( ' utf8 ' ), key ) print ( ' cipherText : ', cipherText ) print ( ' decrypted : ', xor_strings ( cipherText, key ). decode ( ' utf8 ' ) ) # verify if xor_strings ( cipherText, key ). decode ( ' utf8 ' ) = = message : print ( ' Unit test passed ' ) else : print ( ' Unit test failed ' ) See also Vernam cipher Vigenère cipher References Jump up ^ Tutte 1998, p. 3 Jump up ^ Churchhouse 2002, p. 11 Jump up ^ Churchhouse 2002, p. 68 Jump up ^ This was inspired by Richter, Wolfgang ( August 3, 2012 ), `` Unbreakable Cryptography in 5 Minutes '', Crossroads The ACM Magazine for Students, Association for Computing Machinery Bibliography Churchhouse, Robert ( 2002 ), Codes and Ciphers : Julius Caesar, the Enigma and the Internet, Cambridge : Cambridge University Press, ISBN 978 - 0 - 521 - 00890 - 7 Tutte, W.T. ( 19 June 1998 ), Fish and I ( PDF ), retrieved 7 October 2010 Transcript of a lecture given by Prof. Tutte at the University of Waterloo External links XOR encryption for text files on windows with source code Solving the Basic XOR Cipher Retrieved from `` https://en.wikipedia.org/w/index.php?title=XOR_cipher&oldid=832056989 '' Categories : Stream ciphers Hidden categories : Articles needing additional references from July 2009 All articles needing additional references Talk Contents About Wikipedia Español فارسی Hrvatski Русский Slovenščina Українська 中文 Edit links This page was last edited on 23 March 2018, at 15 : 41. About Wikipedia

Question: the xor process is used in which cipher
Answer: additive