#pip install qiskit

from qiskit import *
from qiskit.tools.visualization import plot_histogram

stt="Hello world"
res = ''.join(format(ord(i), 'b') for i in stt)
print(res)

s = res
n = len(s)
circuit = QuantumCircuit(n+1,n)
circuit.x(n)
circuit.barrier()
circuit.h(range(n+1))
circuit.barrier()
for i, tf in enumerate(reversed(s)):
    if tf == '1': 
        circuit.cx(i, n)
circuit.barrier()
circuit.h(range(n+1)) 
circuit.barrier()
circuit.measure(range(n), range(n)) 
%matplotlib inline
circuit.draw(output='mpl')

simulator = Aer.get_backend('qasm_simulator')
result = execute(circuit, backend=simulator, shots=1).result()
from qiskit.visualization import plot_histogram
plot_histogram(result.get_counts(circuit))

kk=result.get_counts()
kkk=list(kk.keys())
strrr=kkk[0]
print(strrr)
res=strrr            #i'm changing res variable, so, now i don't know what's in res
i=0
mainstr=[]
while i<len(res):
  if res[i:i+6] != '100000':
    sk=res[i:i+7]
    i=i+7
    ssk=int(sk, base=2)
    print(ssk)
    mainstr.append(chr(ssk))
  elif res[i:i+6] == '100000':
    i=i+6
    mainstr.append(" ")
print(''.join(mainstr))