

import qiskit
from qiskit.providers import Backend






def  UpperCamelCase_(							_snake_case     :						int ,  _snake_case     :						int			):




			"""simple docstring"""






			__a   ,					__a						   =bin(_snake_case			)[2:], bin(_snake_case			)[2:]  # Remove leading '0b'

			# Ensure that both strings are of the same length
			if len(_snake_case			) > len(_snake_case			):
						__a						   =y.zfill(len(_snake_case			)			)
			else:
						__a						   =x.zfill(len(_snake_case			)			)

			# We need (3 * number of bits in the larger number)+1 qBits
			# The second parameter is the number of classical registers, to measure the result
			__a						   =qiskit.QuantumCircuit((len(_snake_case			) * 3) + 1 ,  len(_snake_case			) + 1			)

			# We are essentially "not-ing" the bits that are 1
			# Reversed because it's easier to perform ops on more significant bits
			for i in range(len(_snake_case			)			):
						if x[::-1][i] == "1":
									circuit.x(_snake_case			)
			for j in range(len(_snake_case			)			):
						if y[::-1][j] == "1":
									circuit.x(len(_snake_case			) + j			)

			return circuit, x, y






def  UpperCamelCase_(							_snake_case     :						qiskit.QuantumCircuit ,  _snake_case     :						int ,  _snake_case     :						int ,  _snake_case     :						int ,  _snake_case     :						int ,  ):




			"""simple docstring"""






			circuit.ccx(_snake_case ,  _snake_case ,  _snake_case			)
			circuit.cx(_snake_case ,  _snake_case			)
			circuit.ccx(_snake_case ,  _snake_case ,  _snake_case			)
			circuit.cx(_snake_case ,  _snake_case			)
			circuit.cx(_snake_case ,  _snake_case			)






def  UpperCamelCase_(							_snake_case     :						int ,  _snake_case     :						int ,  _snake_case     :						Backend = qiskit.Aer.get_backend('aer_simulator'			) ,  ):




			"""simple docstring"""






			if vala < 0 or vala < 0:
						raise ValueError('Both Integers must be positive!'			)

			# Store the Integers
			__a   ,					__a   ,					__a						   =store_two_classics(_snake_case ,  _snake_case			)
			for i in range(len(_snake_case			)			):
						full_adder(_snake_case ,  _snake_case ,  len(_snake_case			) + i ,  len(_snake_case			) + len(_snake_case			) + i ,  len(_snake_case			) + len(_snake_case			) + i + 1			)
						circuit.barrier()  # Optional, just for aesthetics

			# Measure the resultant qBits
			for i in range(len(_snake_case			) + 1			):
						circuit.measure([(len(_snake_case			) * 2) + i] ,  [i]			)

			__a						   =qiskit.execute(_snake_case ,  _snake_case ,  shots=1			).result()

			# The result is in binary. Convert it back to int
			return int(list(res.get_counts()			)[0] ,  2			)


if __name__ == "__main__":
						import doctest

						doctest.testmod()









import os
import sys
import time

from . import transposition_cipher as trans_cipher






def  UpperCamelCase_(							):




			"""simple docstring"""






			__a						   ='Prehistoric Men.txt'
			__a						   ='Output.txt'
			__a						   =int(input('Enter key: '			)			)
			__a						   =input('Encrypt/Decrypt [e/d]: '			)

			if not os.path.exists(_snake_case			):
						print(F'File {input_file} does not exist. Quitting...'			)
						sys.exit()
			if os.path.exists(_snake_case			):
						print(F'Overwrite {output_file}? [y/n]'			)
						__a						   =input('> '			)
						if not response.lower().startswith('y'			):
									sys.exit()

			__a						   =time.time()
			if mode.lower().startswith('e'			):
						with open(_snake_case			) as f:
									__a						   =f.read()
						__a						   =trans_cipher.encrypt_message(_snake_case ,  _snake_case			)
			elif mode.lower().startswith('d'			):
						with open(_snake_case			) as f:
									__a						   =f.read()
						__a						   =trans_cipher.decrypt_message(_snake_case ,  _snake_case			)

			with open(_snake_case ,  'w'			) as output_obj:
						output_obj.write(_snake_case			)

			__a						   =round(time.time() - start_time ,  2			)
			print(('Done (', total_time, 'seconds )')			)


if __name__ == "__main__":
						main()






