Python Forum
Encrypt and decrypt in python using own fixed key
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Encrypt and decrypt in python using own fixed key
#1
Hi I want to encrypt an d decrypt. But I want to use fixed defined key for example: key = "Abcd123". Can some one help how to do it. Thanks in advance. I use below code.
from cryptography.fernet import Fernet
message = "I am python" 
key = Fernet.generate_key()
fernet = Fernet(key)
encMessage = fernet.encrypt(message.encode())
print("original string: ", message)
print("encrypted string: ", encMessage)
decMessage = fernet.decrypt(encMessage).decode()
 
print("decrypted string: ", decMessage)
Reply


Messages In This Thread
Encrypt and decrypt in python using own fixed key - by SriRajesh - Feb-19-2022, 12:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encrypt data in json file help jacksfrustration 1 2,181 Mar-28-2024, 05:16 PM
Last Post: deanhystad
  How to do "fixed size" (wrapping) math in Python? AlexanderWulf 13 5,332 Jul-19-2023, 04:13 PM
Last Post: deanhystad
  Play fixed frequency sound in python 3 jpezz 2 3,951 Feb-07-2021, 08:21 PM
Last Post: jpezz
  Referencing a fixed cell Mark17 2 2,683 Dec-17-2020, 07:14 PM
Last Post: Mark17
  Trying to encrypt and decrypt password into a file rpizw 4 5,488 Aug-12-2020, 05:15 PM
Last Post: bowlofred
  encrypt entire project mattc 2 3,126 Jul-21-2020, 07:05 AM
Last Post: mattc
  The code to decrypt Caeser Cipher. lazerwolf101 2 5,045 May-26-2020, 04:01 PM
Last Post: DT2000
  Paul Rubin p3.py lightweight encrypt/decrypt - is there a python3 version? mason28 0 2,112 Feb-19-2020, 03:38 AM
Last Post: mason28
  Zeep lib, encrypt soap body miha1234 0 3,377 Sep-12-2019, 07:52 AM
Last Post: miha1234
  How to decrypt Blowfish-encrypted text encrypted with Perl's Crypt::CBC? swechsler 0 2,854 Aug-15-2019, 05:24 PM
Last Post: swechsler

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020