2

I've been trying to use ChaCha20 for some school work but I can't seem to import it. When I run the code I get an error

from Crypto.Cipher import ChaCha20
ImportError: cannot import name ChaCha20

I have tried to import other stuff from Crypto.Cipher (AES for example) and I don't get any errors.

EDIT: Even after uninstalling everything and reinstalling pycryptodome (only) I still get the same error any ideias why?

EDIT2: Now I was being an idiot. After uninstalling pycrypto and installing pycryptodome it didn't work because I installed it for python2.x and I was using python3.x to solve it I only had to do was pip3 install pycryptodome

45Yoda
  • 31
  • 6
  • What version are you using? – Makoto Oct 02 '18 at 16:39
  • 5
    You're probably using PyCrypto, but `ChaCha20` is only available in [`PyCryptodome`](https://pycryptodome.readthedocs.io/en/latest/src/cipher/chacha20.html), apparently. – ForceBru Oct 02 '18 at 16:41
  • python 3.6.6 and pycrypto 2.6.1 – 45Yoda Oct 02 '18 at 16:44
  • I also have pycryptodome install version 3.6.6 should i remove pycrypto? – 45Yoda Oct 02 '18 at 16:46
  • 2
    @45Yoda, quote from [docs](https://pycryptodome.readthedocs.io/en/latest/src/introduction.html): "One must avoid having both PyCrypto and PyCryptodome installed at the same time, as they will interfere with each other." – ForceBru Oct 02 '18 at 16:48
  • 1
    I have been trying to delete pycrypto but it says it's a distutils project how can I effectively remove it?? – 45Yoda Oct 03 '18 at 14:10
  • Heh, a name clash between crypto libraries, that's what you get when you try to oversimplify things - such as package names and package handling. 45Yodo, you may have to ask your friendly admin to solve this. Oh, and [this is StackOverflow](https://stackoverflow.com/questions/402359/how-do-you-uninstall-a-python-package-that-was-installed-using-distutils) – Maarten Bodewes Oct 03 '18 at 15:00
  • @45Yoda you should install `pycryptodomex` instead: it's the same as `pycryptodome` but under the separate `Cryptodome` namespace (so you will be able to use `Cryptodome.Cipher.ChaCha20` and experience no clashes with the old pycrypto). – SquareRootOfTwentyThree Oct 08 '18 at 09:27

0 Answers0