Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good two-way encryption library implemented in Python?

The authentication system for an application we're using right now uses a two-way hash that's basically little more than a glorified caesar cypher. Without going into too much detail about what's going on with it, I'd like to replace it with a more secure encryption algorithm (and it needs to be done server-side). Unfortunately, it needs to be two-way and the algorithms in hashlib are all one-way.

What are some good encryption libraries that will include algorithms for this kind of thing?

like image 541
Jason Baker Avatar asked Apr 06 '09 13:04

Jason Baker


People also ask

What is the code generated by taking an input and converting it to cryptographic output using mathematical algorithm?

The ciphertext is a data or text which is encrypted into a secret code using a mathematical algorithm, it can be deciphered using different mathematical Algorithms.


3 Answers

I assume you want an encryption algorithm, not a hash. The PyCrypto library offers a pretty wide range of options. It's in the middle of moving over to a new maintainer, so the docs are a little disorganized, but this is roughly where you want to start looking. I usually use AES for stuff like this.

like image 181
DNS Avatar answered Oct 15 '22 18:10

DNS


If it's two-way, it's not really a "hash". It's encryption (and from the sounds of things this is really more of a 'salt' or 'cypher', not real encryption.) A hash is one-way by definition. So rather than something like MD5 or SHA1 you need to look for something more like PGP.

Secondly, can you explain the reasoning behind the 2-way requirement? That's not generally considered good practice for authentication systems any more.

like image 30
Joel Coehoorn Avatar answered Oct 15 '22 18:10

Joel Coehoorn


PyCrypto supports AES, DES, IDEA, RSA, ElGamal, etc.

I've found the documentation here.

like image 44
nosklo Avatar answered Oct 15 '22 19:10

nosklo