Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert v2 code to v3
#3
Since Python 3, it differs between bytes (raw bytes, no known encoding, binary data) and strings (encoded default with utf8).
Using encryption in Python 3 requires always bytes.

To reduce the pain, you could always use strings as long as you can and when a function requires bytes, then encode them at this place.
If you want to encrypt binary files, you have to open them in binary mode.

str.encode() -> bytes
bytes.decode() -> str
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
convert v2 code to v3 - by pandeyrajeev80 - Aug-23-2018, 10:25 AM
RE: convert v2 code to v3 - by Axel_Erfurt - Aug-23-2018, 10:29 AM
RE: convert v2 code to v3 - by DeaD_EyE - Aug-23-2018, 11:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Review my code: convert a HTTP date header to a datetime object stevendaprano 1 2,051 Dec-17-2022, 12:24 AM
Last Post: snippsat
  convert c code python satyanarayana 5 5,662 Sep-21-2021, 07:45 PM
Last Post: deanhystad
  How to convert a python code to binary? rsurathu 0 1,830 Aug-02-2020, 08:09 AM
Last Post: rsurathu
  Error in the code ->ValueError: could not convert string to float: ' ' eagleboom 1 3,237 Nov-29-2019, 06:19 AM
Last Post: ThomasL
  Can someone please help me convert this simple C ROT cipher code to Python code? boohoo9 5 3,496 Jun-14-2019, 03:02 PM
Last Post: DeaD_EyE
  code help to convert log file to csv format bmunagala 3 12,196 Jan-21-2019, 06:08 PM
Last Post: snippsat
  Convert arduino code to python JDutch 3 22,854 Nov-07-2018, 09:16 PM
Last Post: Larz60+
  Convert C code to Python code lostMarbles 6 32,786 Sep-19-2018, 06:23 AM
Last Post: pcsailor
  How to convert matlab code to python? Ricop522 0 5,244 Jan-13-2018, 01:55 AM
Last Post: Ricop522
  Looking code to convert my strings of line in Dict santosh 1 2,672 Nov-10-2017, 04:49 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

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