Linked Questions

121 votes
9 answers
263k views

How to encode text to base64 in python [duplicate]

I am trying to encode a text string to base64. i tried doing this : name = "your name" print('encoding %s in base64 yields = %s\n'%(name,name.encode('base64','strict'))) But this gives me the ...
sukhvir's user avatar
  • 5,675
47 votes
1 answer
104k views

TypeError: a bytes-like object is required, not 'str' - python 2 to 3 [duplicate]

Hi I am having trouble with this error message. I am new to Python and this Python2 and Python3 is a hassle. I'm not sure what to do here, the error message is as shown below. Using Ticker: AAPL ...
Lasheen Lartey's user avatar
23 votes
1 answer
64k views

Converting a string to and from Base 64 [duplicate]

I am trying to write two programs one that converts a string to base64 and then another that takes a base64 encoded string and converts it back to a string. so far i cant get past the base64 encoding ...
spenman's user avatar
  • 723
20 votes
2 answers
46k views

Encode string representation of integer to base64 in Python 3 [duplicate]

I'm trying to encode an int in to base64, i'm doing that: foo = 1 base64.b64encode(bytes(foo)) expected output: 'MQ==' given output: b'AA==' what i'm doing wrong? Edit: in Python 2.7.2 works ...
fj123x's user avatar
  • 7,610
5 votes
2 answers
8k views

when convert to base 64, TypeError: 'str' does not support the buffer interface [duplicate]

im = Image.open(filePath) # load image self.msg = str(bytearray(list(im.getdata()))) # convert image data to string encodedMsg = base64.b64encode(self.msg) when I was trying to ...
BadEggX's user avatar
  • 195
2 votes
2 answers
14k views

How to encode a string with base64 in python 3 and remove the new lines [duplicate]

Background: I'm trying to encode my string of a username and password to base 64 for a SOAP request in python 3.5.2. Code: username = 'Universal API/uAPI7054626850-8a6c09f0' password = '...
IFH's user avatar
  • 161
-2 votes
1 answer
351 views

TypeError: 'str' does not support the buffer interface - using base64.b64encode [duplicate]

I've taken a look at many other "Questions that may already have your answer", but didn't come across any that hit directly on the issue I'm running into. Here's my Python 2 snippet: ...
colby_schrauth's user avatar
0 votes
0 answers
209 views

pycrypto not encrypting in ascii or unicode [duplicate]

I am using pycrypto to encrypt and decrypt a message using a key. I followed some examples and finally wrote my own. But it turns out that the encrypted message is not in unicode or ascii. I need to ...
Himanshu Mishra's user avatar
1 vote
2 answers
15k views

How to decode base 64 format in jmeter?

Does anyone know a solution to decode a base 64 format string in JMeter? I have to decode the a response, but i don't want to reinvent the wheel... Do i have to write the code by myself (hope not)? ...
luistm's user avatar
  • 1,027
6 votes
1 answer
20k views

Using requests to send byte-array to webservice using http post

Currently I'm trying to send a byte-array to a webservice, but i get the error message, that a bytearray is not serializeable: TypeError: bytearray(b'') is not JSON serializable I'm using the ...
BendEg's user avatar
  • 21.3k
2 votes
1 answer
8k views

Encoding a string to base64 in Python 2.x vs Python 3.x

In Python 2, I used to could do this: >>> var='this is a simple string' >>> var.encode('base64') 'dGhpcyBpcyBhIHNpbXBsZSBzdHJpbmc=\n' Easy! Unfortunately, this don't work in Python ...
Jon Red's user avatar
  • 136
7 votes
4 answers
4k views

Get Binary Representation of PIL Image Without Saving

I am writing an application that uses images intensively. It is composed of two parts. The client part is written in Python. It does some preprocessing on images and sends them over TCP to a Node.js ...
JackOrJones's user avatar
1 vote
1 answer
2k views

Trying to store raw bytes inside my one Python script file

I am currently working on a Python script that will be able to hide all binary files inside itself. It does this by reading all binary data from the targeted file and then stores it in a list inside ...
user2726067's user avatar
0 votes
1 answer
5k views

Python 3.7 TypeError: a bytes-like object is required, not 'str'

I have these two strings: client_id = "id_str" client_secret = "secret_str" And I must pass them like so: def getToken(code, client_id, client_secret, redirect_uri): body = { "grant_type"...
8-Bit Borges's user avatar
  • 10.1k
5 votes
1 answer
3k views

Storing matplotlib images in S3 with S3.Object().put() on boto3 1.5.36

Amongst other things I am drawing plots using matplotlib, which I would like to immediately store as S3 objects. According to the answers provided in this and this other question and the fine manual, ...
user1129682's user avatar
  • 1,119

15 30 50 per page