Mo J. Mughrabi
Mo J. Mughrabi

Reputation: 6997

Encrypting and decrypting in python without using special characters

I would like to encrypt certain strings and use them in a HTTP GET protocol without resulting in an error if there are special characters in URL. Any advice on how can I convert strings to an encryption of that sort and decrypt it again? what encryption library would be most suitable for this scenario?

Upvotes: 2

Views: 1083

Answers (1)

Thomas Orozco
Thomas Orozco

Reputation: 55233

Encrypt and decrypt using a standard encryption algorithm (from a library), and encode the encrypted sting using base 64 (from the base64 module).

Your workflow becomes:

  1. Encrypt the plaintext using a crypto library (gives you the ciphertext)
  2. Encode the ciphertext using base 64 (gives you an encoded ciphertext, this is URL proof)
  3. Decode the encoded ciphertext using base 64 (gives you the ciphertext back)
  4. Decrypt the ciphertext using a crypto library (gives you the plaintext back)

A few encryption libraries:

Upvotes: 7

Related Questions