



import numpy as np
import qiskit

def        __a			(   __lowerCAmelCase = 8      ,	__lowerCAmelCase = None   )     ->     str:
					SCREAMING_SNAKE_CASE							:     Optional[int]						=				np.random.default_rng(seed=__lowerCAmelCase   )

					# Roughly 25% of the qubits will contribute to the key.
					# So we take more than we need.
					SCREAMING_SNAKE_CASE							:     Optional[int]						=				6 * key_len
					# Measurement basis for Alice's qubits.
					SCREAMING_SNAKE_CASE							:     Any						=				rng.integers(2      ,	size=__lowerCAmelCase   )
					# The set of states Alice will prepare.
					SCREAMING_SNAKE_CASE							:     List[Any]						=				rng.integers(2      ,	size=__lowerCAmelCase   )
					# Measurement basis for Bob's qubits.
					SCREAMING_SNAKE_CASE							:     List[Any]						=				rng.integers(2      ,	size=__lowerCAmelCase   )

					# Quantum Circuit to simulate BB84
					SCREAMING_SNAKE_CASE							:     List[Any]						=				qiskit.QuantumCircuit(__lowerCAmelCase      ,	name='BB84'   )

					# Alice prepares her qubits according to rules above.
					for index, _ in enumerate(__lowerCAmelCase   ):
										if alice_state[index] == 1:
															bbaa_circ.x(__lowerCAmelCase   )
										if alice_basis[index] == 1:
															bbaa_circ.h(__lowerCAmelCase   )
					bbaa_circ.barrier()

					# Bob measures the received qubits according to rules above.
					for index, _ in enumerate(__lowerCAmelCase   ):
										if bob_basis[index] == 1:
															bbaa_circ.h(__lowerCAmelCase   )

					bbaa_circ.barrier()
					bbaa_circ.measure_all()

					# Simulate the quantum circuit.
					SCREAMING_SNAKE_CASE							:     List[str]						=				qiskit.Aer.get_backend('aer_simulator'   )
					# We only need to run one shot because the key is unique.
					# Multiple shots will produce the same key.
					SCREAMING_SNAKE_CASE							:     Optional[int]						=				qiskit.execute(__lowerCAmelCase      ,	__lowerCAmelCase      ,	shots=1      ,	seed_simulator=__lowerCAmelCase   )
					# Returns the result of measurement.
					SCREAMING_SNAKE_CASE							:     Optional[Any]						=				job.result().get_counts(__lowerCAmelCase   ).most_frequent()

					# Extracting the generated key from the simulation results.
					# Only keep measurement results where Alice and Bob chose the same basis.
					SCREAMING_SNAKE_CASE							:     Tuple						=				''.join(
					    [
					        result_bit
					        for alice_basis_bit, bob_basis_bit, result_bit in zip(
					            __lowerCAmelCase      ,	__lowerCAmelCase      ,	__lowerCAmelCase   )
					        if alice_basis_bit == bob_basis_bit
					    ]   )

					# Get final key. Pad with 0 if too short, otherwise truncate.
					SCREAMING_SNAKE_CASE							:     int						=				gen_key[:key_len] if len(__lowerCAmelCase   ) >= key_len else gen_key.ljust(__lowerCAmelCase      ,	'0'   )
					return key


if __name__ == "__main__":
			print(f"""The generated key is : {bbaa(8, seed=0)}""")
			from doctest import testmod

			testmod()




from datetime import datetime

import requests

def        __a			(   __lowerCAmelCase   )     ->     bytes:
					SCREAMING_SNAKE_CASE							:     int						=				'https://downloadgram.net/wp-json/wppress/video-downloader/video?url='
					SCREAMING_SNAKE_CASE							:     Any						=				requests.get(base_url + url   ).json()[0]['urls'][0]['src']
					return requests.get(__lowerCAmelCase   ).content


if __name__ == "__main__":
			_lowerCamelCase    :		List[Any]		      =    input("""Enter Video/IGTV url: """).strip()
			_lowerCamelCase    :		int		      =    f"""{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4"""
			with open(file_name, """wb""") as fp:
						fp.write(download_video(url))
			print(f"""Done. Video saved to disk as {file_name}.""")