I was wondering how can we convert data into a hash using Qiskit quantum computer? e.g, this code below will generate a SHA256 hash based on random data.

data = str(45) + "f5a55af7ea98" + "8e84ad6f84f66"
hash = hashlib.sha256(data.encode()).hexdigest()

result: d73ee4cd204acb431745ba79154dac7d73bfe05608d3911bb432bc8b4a8addf9

I know the answer is not easy, although the question looks simple.

Thank you


1 Answer 1


There is no current implementation of SHA256 in Qiskit. Reasons for that include:

  • its implementation could be rather complicated, including a large number of ancilla qubits;
  • it would require a huge number of qubits: 256 for the output only, as much as you want for the input;
  • the depth of the associated circuit would be so large that, considering the performance of current quantum computers, you would get nothing but noise at the end of the computation.
  • $\begingroup$ How about running it on a simulator? $\endgroup$ May 20 at 16:23
  • $\begingroup$ @ZakariaHalloumi that's not possible, as simulation would require more than $2^{256}$ bits of memory, which is way, way more than the number of atoms in the universe. Remember that simulation only helps designing quantum algorithms, it doesn't provide any speedup when compared to classical algorithms $\endgroup$ May 20 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.