Python Forum
how to encode and decode same value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to encode and decode same value
#1
Hi.
I obtain these data:
ADhlamtsOXdreXE2eAA0VFpWTGJBWDdSZW83d3AwYnJnNlVnSEpRcTlvR0wwMTlldUhSelJ6bXRtTTRnbmUxU
I'm tring to decode and then encode to check that I have the same result but the second python program not gives the result of the first. I'll explain better with examples:


 $ more decode.py
import base64
code = "ADhlamtsOXdreXE2eAA0VFpWTGJBWDdSZW83d3AwYnJnNlVnSEpRcTlvR0wwMTlldUhSelJ6bXRtTTRnbmUxU
HpERklwdnFGTzN0eFVzNXgxZlN5"
result=base64.b64decode(code)
print result
# b'admin:202cb962ac59075b964b07152d234b70'
 $ more code.py
import base64
code = "8ejkl9wkyq6x4TZVLbAX7Reo7wp0brg6UgHJQq9oGL019euHRzRzmtmM4gne1PzDFIpvqFO3txUs5x1fSy"
result=base64.b64encode(code)
print result
# b'admin:202cb962ac59075b964b07152d234b70'
 $ python decode.py
8ejkl9wkyq6x4TZVLbAX7Reo7wp0brg6UgHJQq9oGL019euHRzRzmtmM4gne1PzDFIpvqFO3txUs5x1fSy
$ python code.py
OGVqa2w5d2t5cTZ4NFRaVkxiQVg3UmVvN3dwMGJyZzZVZ0hKUXE5b0dMMDE5ZXVIUnpSem10bU00Z25lMVB6REZJcHZxRk8zdHhVczV4MWZTeQ=
When I code I need obtain ADhlamtsOXdreXE2eAA0VFpWTGJBWDdSZW83d3AwYnJnNlVnSEpRcTlvR0wwMTlldUhSelJ6bXRtTTRnbmUxU


What am I doing wrong? Many thanks and sorry for my English!
Reply


Messages In This Thread
how to encode and decode same value - by absolut - Sep-07-2020, 01:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encode/decode to show correct country letters in a CTk combobox janeik 2 763 Sep-02-2023, 09:46 AM
Last Post: janeik
Question UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 562: ord ctrldan 23 5,079 Apr-24-2023, 03:40 PM
Last Post: ctrldan
  Decode string ? JohnnyCoffee 1 847 Jan-11-2023, 12:29 AM
Last Post: bowlofred
  UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin Armandito 6 2,825 Apr-29-2022, 12:36 PM
Last Post: Armandito
  'NoneType' object has no attribute 'encode' bhagyashree 6 8,946 Nov-05-2020, 03:50 PM
Last Post: deanhystad
  TypeError: ENCODE Method, str instead of byte Rajath 1 2,810 May-09-2020, 06:05 PM
Last Post: bowlofred
  struct.decode() and '\0' deanhystad 1 3,269 Apr-09-2020, 04:13 PM
Last Post: TomToad
  Getting decode error. shankar 8 10,485 Sep-20-2019, 10:05 AM
Last Post: tinman
  asyncio encode and decode, how good are they? CoderOne 2 2,381 Sep-03-2019, 11:06 PM
Last Post: wavic
  UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 23: c kapilan15 2 4,467 Jan-14-2019, 09:11 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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