Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I encrypt email and decrypt it back using python default library set?

Of course similar questions have been asked in stackoverflow but I don't want to use any third party library like Crypto or something. So I need to generate a ciphertext from a user email and decrypt it back to plaintext. How can I do this in python?

like image 572
None-da Avatar asked Apr 30 '09 12:04

None-da


People also ask

Does Python have built in encryption?

Python has no built-in encryption schemes, no. You also should take encrypted data storage serious; trivial encryption schemes that one developer understands to be insecure and a toy scheme may well be mistaken for a secure scheme by a less experienced developer. If you encrypt, encrypt properly.

Is Fernet encryption secure?

The result of this encryption is known as a “Fernet token” and has strong privacy and authenticity guarantees. data (bytes) – The message you would like to encrypt. A secure message that cannot be read or altered without the key. It is URL-safe base64-encoded.


2 Answers

A third-party system is your best bet.
If you really can't/don't want to use a third-party, maybe something simple would suffice.

One of the simpler algorithms is the Tiny Encryption Algorithm (TEA). Here's an example of a Python implementation that you could start with.

like image 181
Jason Coon Avatar answered Sep 29 '22 15:09

Jason Coon


Yes, you can. Read http://www.amk.ca/python/code/crypto.html You'll find an answer there ;)

You're question is not concrete enough to say more. You may want to read http://en.wikipedia.org/wiki/Cryptography#Modern_cryptography

Cheers, Tuergeist

Update: No, you cannot. (with build in functionality due to export restrictions, see http://docs.python.org/library/crypto.html) But you can, if you're implementing you own algorithm (bad idea). So, the BEST solution is, to use the extension recommended by python core developers. See post above.

Cheers again.

like image 41
tuergeist Avatar answered Sep 29 '22 15:09

tuergeist