How do I encrypt and decrypt a string in python?

后端 未结 8 1458
忘了有多久
忘了有多久 2020-11-28 05:36

I have been looking for sometime on how to encrypt and decrypt a string. But most of it is in 2.7 and anything that is using 3.2 is not letting me print it or add it to a st

8条回答
  •  暖寄归人
    2020-11-28 06:18

    You can do this easily by using the library cryptocode. Here is how you install:

    pip install cryptocode
    

    Encrypting a message (example code):

    import cryptocode
    
    encoded = cryptocode.encrypt("mystring","mypassword")
    ## And then to decode it:
    decoded = cryptocode.decrypt(encoded, "mypassword")
    

    Documentation can be found here

提交回复
热议问题