Re: py2 to 3 base64 issues

2019-08-09 Thread Larry Martell
I have some python 2 code: > >> > > >> > def decode(key, string): > >> >decoded_chars = [] > >> >string = base64.urlsafe_b64decode(string) > >> >for i in range(len(string)): > >> >key_c = key[i

Re: py2 to 3 base64 issues

2019-08-09 Thread MRAB
On 2019-08-09 19:21, Larry Martell wrote: On Fri, Aug 9, 2019 at 12:23 PM Chris Angelico wrote: On Sat, Aug 10, 2019 at 2:09 AM Larry Martell wrote: > > I have some python 2 code: > > def decode(key, string): >decoded_chars = [] > string = base64.urlsaf

Re: py2 to 3 base64 issues

2019-08-09 Thread Larry Martell
On Fri, Aug 9, 2019 at 12:23 PM Chris Angelico wrote: > > On Sat, Aug 10, 2019 at 2:09 AM Larry Martell wrote: > > > > I have some python 2 code: > > > > def decode(key, string): > >decoded_chars = [] > >string = base64.urlsafe_b64de

Re: py2 to 3 base64 issues

2019-08-09 Thread MRAB
On 2019-08-09 17:06, Larry Martell wrote: I have some python 2 code: def decode(key, string): decoded_chars = [] string = base64.urlsafe_b64decode(string) for i in range(len(string)): key_c = key[i % len(key)] encoded_c = chr(abs(ord(string[i

Re: py2 to 3 base64 issues

2019-08-09 Thread Chris Angelico
On Sat, Aug 10, 2019 at 2:09 AM Larry Martell wrote: > > I have some python 2 code: > > def decode(key, string): >decoded_chars = [] > string = base64.urlsafe_b64decode(string) >for i in range(len(string)): >key_c = key[i % len(key)] >

py2 to 3 base64 issues

2019-08-09 Thread Larry Martell
I have some python 2 code: def decode(key, string): decoded_chars = [] string = base64.urlsafe_b64decode(string) for i in range(len(string)): key_c = key[i % len(key)] encoded_c = chr(abs(ord(string[i]) - ord(key_c) % 256

Re: Decodificar base64 en Odoo 12

2019-03-06 Thread Peter Otten
> >> >> > Hola a todos, tengo un problema al decodificar el contenido de una >> >> > variable base64. >> >> > >> >> > De esta manera lo hago: >> >> > >> >> > cfdi = base64.b64decode(inv.l10n_mx_edi_cfdi) >>

Re: Decodificar base64 en Odoo 12

2019-03-05 Thread angiielovee177
ificar el contenido de una > >> > variable base64. > >> > > >> > De esta manera lo hago: > >> > > >> > cfdi = base64.b64decode(inv.l10n_mx_edi_cfdi) > >> > > >> > > >> > > >> > Al momento

Re: Decodificar base64 en Odoo 12

2019-03-05 Thread Peter Otten
angiielovee...@gmail.com wrote: > El lunes, 4 de marzo de 2019, 11:07:40 (UTC-6), Peter Otten escribió: >> Angie GL wrote: >> >> > Hola a todos, tengo un problema al decodificar el contenido de una >> > variable base64. >> > >> > De esta

Re: Decodificar base64 en Odoo 12

2019-03-04 Thread angiielovee177
El lunes, 4 de marzo de 2019, 11:07:40 (UTC-6), Peter Otten escribió: > Angie GL wrote: > > > Hola a todos, tengo un problema al decodificar el contenido de una > > variable base64. > > > > De esta manera lo hago: > > > > cfdi = base64.b64decode(i

Re: Decodificar base64 en Odoo 12

2019-03-04 Thread Peter Otten
Angie GL wrote: > Hola a todos, tengo un problema al decodificar el contenido de una > variable base64. > > De esta manera lo hago: > > cfdi = base64.b64decode(inv.l10n_mx_edi_cfdi) > > > > Al momento de decodificar el resultado que me envía es esto: > >

Decodificar base64 en Odoo 12

2019-03-04 Thread Angie GL
Hola a todos, tengo un problema al decodificar el contenido de una variable base64. De esta manera lo hago: cfdi = base64.b64decode(inv.l10n_mx_edi_cfdi) Al momento de decodificar el resultado que me envía es esto: b'\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n' Algu

Re: base64.b64encode(data)

2016-06-21 Thread Steven D'Aprano
follow their interpretation. The RFC is a network protocol, Python is a programming language, and our libraries can do whatever makes sense for *programming*. And the people who migrated the Python 2 base64 lib to Python 3 thought that it made more sense to have the functions operate on bytes an

Re: base64.b64encode(data)

2016-06-13 Thread Random832
On Mon, Jun 13, 2016, at 19:12, Gregory Ewing wrote: > They could maybe be made a bit cheaper still by arranging > some way for a bytes object and an ascii-only str object > to share underlying storage. While we're at it, why not allow bytes to share storage with FSR latin-1 strings and the cached

Re: base64.b64encode(data)

2016-06-13 Thread Gregory Ewing
Chris Angelico wrote: Maybe what Python needs is an "ascii" type that's a subclass of both str and bytes, and requires that the contents be <0x80. It is text, so it can be combined with text strings; but it is also bytes, so when you combine it with bytes strings, it'll behave as most people expe

Re: base64.b64encode(data)

2016-06-13 Thread Gregory Ewing
Michael Torrie wrote: On 06/12/2016 11:16 PM, Steven D'Aprano wrote: Squirt it down a wire as bytes? Almost certainly. Sometimes yes. But not always. And even when the ultimate destination is a wire, a Python programmer is more likely to be accessing the wire through some high-level interf

Re: base64.b64encode(data)

2016-06-13 Thread Chris Angelico
ext. That's the whole point of base64! Maybe what Python needs is an "ascii" type that's a subclass of both str and bytes, and requires that the contents be <0x80. It is text, so it can be combined with text strings; but it is also bytes, so when you combine it with byte

Re: base64.b64encode(data)

2016-06-13 Thread Michael Torrie
On 06/12/2016 11:16 PM, Steven D'Aprano wrote: > "Safe to transmit in text protocols" surely should mean "any Unicode code > point", since all of Unicode is text. What's so special about the base64 > ones? > > Well, that depends on your context. For s

Re: base64.b64encode(data)

2016-06-13 Thread Random832
On Mon, Jun 13, 2016, at 06:35, Steven D'Aprano wrote: > But this is a Python forum, and Python 3 is a language that tries > very, very hard to keep a clean separation between bytes and text, Yes, but that doesn't mean that you're right about which side of that divide bas

Re: base64.b64encode(data)

2016-06-13 Thread Steven D'Aprano
onger the case, and hasn't been for, well to be honest it was *never* the case that 0x48 unambiguously meant 'H', and it is certainly not the case now. The bottom line is that critical use-cases for base64 involve transmitting bytes, not writing arbitrary Unicode, and that's w

Re: base64.b64encode(data)

2016-06-12 Thread Marko Rauhamaa
Random832 : > base64 characters are *characters*, not *bytes* Ok, I ran into the same surprise just two days ago. But is this a big deal? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: base64.b64encode(data)

2016-06-12 Thread Random832
ou could write it to a file. If the file is opened in binary mode, > you have to encode the Unicode string to bytes before you can write > it. If the file is opened in text mode, Python will accept your > Unicode string and encode it for you, which could introduce non- > base64 charact

Re: base64.b64encode(data)

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 01:20 pm, Random832 wrote: > On Sun, Jun 12, 2016, at 22:22, Steven D'Aprano wrote: >> That's because base64 is a bytes-to-bytes transformation. It has >> nothing to do with unicode encodings. > > Nonsense. base64 is a binary-to-text encodin

Re: base64.b64encode(data)

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 22:22, Steven D'Aprano wrote: > That's because base64 is a bytes-to-bytes transformation. It has > nothing to do with unicode encodings. Nonsense. base64 is a binary-to-text encoding scheme. The output range is specifically chosen to be safe to transmit i

Re: base64.b64encode(data)

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 04:56 am, Marcin Rak wrote: > Hi to everyone. > > Let's say I have some binary data, be it whatever, in the 'data' variable. > After calling the following line > > b64_encoded_data = base64.b64encode(data) > > my b64_encoded_data v

Re: base64.b64encode(data)

2016-06-12 Thread Marko Rauhamaa
Marcin Rak : > b64_encoded_data = base64.b64encode(data) > > my b64_encoded_data variables holds, would you believe it, a string as > bytes!. It doesn't much matter one way or another. The logic is that whenever you encode objects, you typically want the output as bytes. However

base64.b64encode(data)

2016-06-12 Thread Marcin Rak
Hi to everyone. Let's say I have some binary data, be it whatever, in the 'data' variable. After calling the following line b64_encoded_data = base64.b64encode(data) my b64_encoded_data variables holds, would you believe it, a string as bytes!. That is, the b64_encoded_data

base64 convert to binary by binascii is that right?

2014-07-11 Thread Frank Liou
conn = engine.connect() encoded = base64.b64encode(getbody) binary_string = binascii.a2b_base64(encoded) puresql = sqla.text("INSERT INTO friends(name) VALUES(:binary_string)") conn.execute(puresql,binary_string = binary_string) first getbody trans to base64 then

Re: Ldap module and base64 oncoding

2013-05-28 Thread Michael Ströder
Joseph L. Casale wrote: > I had some time today, so I attempted to open the ldif files in binary mode > to simply > work with the raw byte strings but the moment the first entry was parsed, > parse() > stumbled on a character in the first entries dict and passed a dn of None for > the last half?

RE: Ldap module and base64 oncoding

2013-05-27 Thread Joseph L. Casale
> Note that all modules in python-ldap up to 2.4.10 including module 'ldif' > expect raw byte strings to be passed as arguments. It seems to me you're > passing a Unicode object in the entry dictionary which will fail in case an > attribute value contains NON-ASCII chars. Yup, I was. > python-lda

Re: Ldap module and base64 oncoding

2013-05-27 Thread Michael Ströder
site-packages\ldif.py", line 142, in > _unparseAttrTypeandValue > self._unfoldLDIFLine(':: > '.join([attr_type,base64.encodestring(attr_value).replace('\n','')])) > File "C:\Python27\lib\base64.py", line 315, in encodestring > pieces.app

Re: Ldap module and base64 oncoding

2013-05-26 Thread dieter
Python27\lib\site-packages\ldif.py", line 142, in > _unparseAttrTypeandValue > self._unfoldLDIFLine(':: > '.join([attr_type,base64.encodestring(attr_value).replace('\n','')])) > File "C:\Python27\lib\base64.py", line 315, in encodestri

RE: Ldap module and base64 oncoding

2013-05-26 Thread Joseph L. Casale
n't have much control on the data in the directory and I do know that DN's have non ascii characters unique to the > I wonder what the string really is. At least the base64-encoding you provided > before decodes as UTF-8 but I'm not sure whether it's the right sequence

Re: Ldap module and base64 oncoding

2013-05-26 Thread Michael Ströder
Joseph L. Casale wrote: >> I'm not sure what exactly you're asking for. >> Especially "is not being interpreted as a string requiring base64 encoding" >> is >> written without giving the right context. >> >> So I'm just guessing that th

RE: Ldap module and base64 oncoding

2013-05-26 Thread Joseph L. Casale
> I'm not sure what exactly you're asking for. > Especially "is not being interpreted as a string requiring base64 encoding" is > written without giving the right context. > > So I'm just guessing that this might be the usual misunderstandings with use &

Re: Ldap module and base64 oncoding

2013-05-26 Thread Michael Ströder
Joseph L. Casale wrote: >> Can you give an example of the code you have? > > I actually just overrode the regex used by the method in the LDIFWriter class > to be far more broad > about what it interprets as a safe string. Are you sure that you fully understood RFC 2849 before doing this? Which

Re: Ldap module and base64 oncoding

2013-05-26 Thread Michael Ströder
Joseph L. Casale wrote: > I have some data I am working with that is not being interpreted as a string > requiring > base64 encoding when sent to the ldif module for output. > > The base64 string parsed is ZGV0XDMzMTB3YmJccGc= and the raw string is > det\3310wbb\p

RE: Ldap module and base64 oncoding

2013-05-25 Thread Joseph L. Casale
> Can you give an example of the code you have? I actually just overrode the regex used by the method in the LDIFWriter class to be far more broad about what it interprets as a safe string. I really need to properly handle reading, manipulating and writing non ascii data to solve this... Shame

RE: Ldap module and base64 oncoding

2013-05-24 Thread Carlos Nepomuceno
Can you give an example of the code you have? > From: jcas...@activenetwerx.com > To: python-list@python.org > Subject: Ldap module and base64 oncoding > Date: Fri, 24 May 2013 21:00:01 + > > I have some data I am working with

Ldap module and base64 oncoding

2013-05-24 Thread Joseph L. Casale
I have some data I am working with that is not being interpreted as a string requiring base64 encoding when sent to the ldif module for output. The base64 string parsed is ZGV0XDMzMTB3YmJccGc= and the raw string is det\3310wbb\pg. I'll admit my understanding of the handling requirements o

decode php base64

2013-03-17 Thread Peter juliano
Not long ago, my friend resignation of the company. He left a few app's in php, some of those files are hashed with base64 code, he told me that those files handle http request on the server and some security rules. Because i'm migrating all these applications on django. I do not r

Re: 3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Ethan Furman
Terry Reedy wrote: On 2/28/2011 3:51 PM, Ethan Furman wrote: The deprecation warning has gone away in 3.2, No, still there: def encodestring(s): """Legacy alias of encodebytes().""" import warnings warnings.warn("encodestring() is a deprecated alias, use encodebytes()",

Re: 3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Terry Reedy
On 2/28/2011 3:51 PM, Ethan Furman wrote: Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> import base64 --> base64.encodestring(b&#

Re: 3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Robert
On 2011-02-28 15:51:32 -0500, Ethan Furman said: Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> import base64 --> bas

3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Ethan Furman
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> import base64 --> base64.encodestring(b'this is a test') __main__:1: Deprec

m2crypto, base64, quoted-printable, xml

2010-12-02 Thread Milan Petrasek
Hi, I have encrypted signed smime message with xml file. Messages are constructed: 1) xml file is embedded to MIME message as attacment (Content-Disposition: attachment;). 2) over whole content MIME message is signed by PKCS#7 and encoded Base64. 3) This message is encrypted by public key. I

Re: Why the inconsistent of those two base64 methods?

2010-05-12 Thread Mensanator
On May 12, 4:20 am, Maarten wrote: > On May 12, 6:04 am, Leo Jay wrote: > > > I'd like to encode a string in base64, but I found a inconsistent of > > two methods: > > > >>> 'aaa'.encode('base64') > > 'YWFh\n' > >

Re: Why the inconsistent of those two base64 methods?

2010-05-12 Thread Maarten
On May 12, 6:04 am, Leo Jay wrote: > I'd like to encode a string in base64, but I found a inconsistent of > two methods: > > >>> 'aaa'.encode('base64') > 'YWFh\n' > >>> import base64 > >>> base64.b64encode('a

Why the inconsistent of those two base64 methods?

2010-05-11 Thread Leo Jay
I'd like to encode a string in base64, but I found a inconsistent of two methods: >>> 'aaa'.encode('base64') 'YWFh\n' >>> import base64 >>> base64.b64encode('aaa') 'YWFh' >>> as you can see, the res

Re: base64 Incorrect Padding

2009-07-31 Thread Gabriel Genellina
En Fri, 31 Jul 2009 18:58:43 -0300, bfrederi escribió: So what if I used a different encoding that isn't ASCII? Like UTF-8? Would that give me lengths that are multiples of 4 based on how the characters are represented? Or would I still need to pad with '='? It doesn

Re: base64 Incorrect Padding

2009-07-31 Thread MRAB
bfrederi wrote: So what if I used a different encoding that isn't ASCII? Like UTF-8? Would that give me lengths that are multiples of 4 based on how the characters are represented? Or would I still need to pad with '='? I think that when it says Base-64 it's talking about the byte values used f

Re: base64 Incorrect Padding

2009-07-31 Thread bfrederi
So what if I used a different encoding that isn't ASCII? Like UTF-8? Would that give me lengths that are multiples of 4 based on how the characters are represented? Or would I still need to pad with '='? -- http://mail.python.org/mailman/listinfo/python-list

Re: base64 Incorrect Padding

2009-07-31 Thread MRAB
Max Erickson wrote: MRAB wrote: Brandon Fredericks wrote: I did a search within this group, but couldn't find any information on this. I am sending base64 encoded data as the content over http using urllib2 urlopen. When I receive the data and attempt to decode it, I get an "

Re: base64 Incorrect Padding

2009-07-31 Thread Max Erickson
MRAB wrote: > Brandon Fredericks wrote: >> I did a search within this group, but couldn't find any >> information on this. >> >> I am sending base64 encoded data as the content over http using >> urllib2 urlopen. When I receive the data and attempt to dec

Re: base64 Incorrect Padding

2009-07-31 Thread MRAB
Brandon Fredericks wrote: I did a search within this group, but couldn't find any information on this. I am sending base64 encoded data as the content over http using urllib2 urlopen. When I receive the data and attempt to decode it, I get an "Incorrect Padding" error. Is there

Re: base64 Incorrect Padding

2009-07-31 Thread Peter Otten
Brandon Fredericks wrote: > I did a search within this group, but couldn't find any information on > this. > > I am sending base64 encoded data as the content over http using > urllib2 urlopen. When I receive the data and attempt to decode it, I > get an "Incorrec

base64 Incorrect Padding

2009-07-31 Thread Brandon Fredericks
I did a search within this group, but couldn't find any information on this. I am sending base64 encoded data as the content over http using urllib2 urlopen. When I receive the data and attempt to decode it, I get an "Incorrect Padding" error. Is there a simple way to fix this?

Re: uncompress base64-gzipped string

2009-06-14 Thread Lawrence D'Oliveiro
In message , John Machin wrote: > What a long journey: parse xml, base64 decode, gunzip, > and you're still not home; next stop is struct.unpack ... Binary data in an XML file?? Were these the same folks who worked on OOXML, by any chance? -- http://mail.python.org/mailman/list

Re: uncompress base64-gzipped string

2009-06-13 Thread Scott David Daniels
Niels Egberts wrote: On Sat, Jun 13, 2009 at 4:38 AM, John Machin wrote: ... And thanks for the tip on struct.unpack I managed to get a list of integers to work with. You might make do with array.fromstring (perhaps using .byteswap afterwards) to get your numbers if you are talking more than a

Re: uncompress base64-gzipped string

2009-06-13 Thread Niels Egberts
On Sat, Jun 13, 2009 at 4:38 AM, John Machin wrote: > | >>> guff[:100] > | '\x1b\x00\x00\x00\x1b\x00\x00\x00\x1b\x00\x00\x00 [snip] > > What a long journey: parse xml, base64 decode, gunzip, > and you're still not home; next stop is struct.unpack ... > >

Re: uncompress base64-gzipped string

2009-06-12 Thread John Machin
Niels Egberts gmail.com> writes: > zlib.error: Error -3 while decompressing data: incorrect header check > > How can I solve this? The link you quoted says "you need to first base64 decode the string, then gunzip the resulting data" ... so gunzip it: | >>> s0 =

uncompress base64-gzipped string

2009-06-12 Thread Niels Egberts
I'm creating a game in python and I want to a level editor called 'tiled'. It ouputs a .xml file with base64-gzipped information. Then every 4 bytes represents a number. See the following link: http://www.mapeditor.org/wiki/Examining_the_map_format To start I tried: code = b

Problem with base64 mimeparts and email.*

2009-04-22 Thread seal
Hello, I'm writing a rss2mbox program as a first python project. I'm using feedparser, mailbox and email.* modules. I have a problem. The produced MIME- message (see below) seems right, as far as I know, but the base64-encoded part isn't decoded in the MUAs. I've tried cone

Re: python3.0 base64 error

2009-01-17 Thread Terry Reedy
yang michael wrote: I use base64 module on python3.0 like: import base64 b="hello world" a=base64.b64encode(b) print(a) but when i run it,it catch a error: Traceback (most recent call last): File "/home/jackie-yang/yd5m19/pythonstudy/test.py", line 4, in a=base64

Re: python3.0 base64 error

2009-01-17 Thread MRAB
yang michael wrote: I use base64 module on python3.0 like: import base64 b="hello world" Try: b = b"hello world" instead. a=base64.b64encode(b) print(a) but when i run it,it catch a error: Traceback (most recent call last): File "/home/jackie-yang/yd5m19/p

python3.0 base64 error

2009-01-17 Thread yang michael
I use base64 module on python3.0 like: import base64 b="hello world" a=base64.b64encode(b) print(a) but when i run it,it catch a error: Traceback (most recent call last): File "/home/jackie-yang/yd5m19/pythonstudy/test.py", line 4, in a=base64.b64encode(b) File "

Re: help me~!about base64

2008-12-02 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > my code: > − > import base64 > def deflashget(st): > if st.startswith('Flashget://'): > return base64.decodestring(st[len('Flashget://'):])[10:-10] > elif st.st

Re: help me~!about base64

2008-12-02 Thread ylj798
On 12月3日, 上午3时26分, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On Tue, Dec 2, 2008 at 2:08 PM, <[EMAIL PROTECTED]> wrote: > >>>>print base64.__file__ > > /usr/lib/python2.5/base64.pyc > > That looks fine, and matches what I have on my linux box.

Re: help me~!about base64

2008-12-02 Thread Jerry Hill
On Tue, Dec 2, 2008 at 2:08 PM, <[EMAIL PROTECTED]> wrote: >>>>print base64.__file__ > /usr/lib/python2.5/base64.pyc That looks fine, and matches what I have on my linux box. Your code works fine for me when I run it, so I'm out of ideas. -- Jerry -- http://mail.p

Re: help me~!about base64

2008-12-02 Thread ylj798
On 12月3日, 上午1时50分, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > 2008/12/2 <[EMAIL PROTECTED]>: > > > it's run ,Eric gave me error,the error is "'module'objecthasno > >attribute'decodestring'", > > Do you have your own

Re: help me~!about base64

2008-12-02 Thread Jerry Hill
2008/12/2 <[EMAIL PROTECTED]>: > it's run ,Eric gave me error,the error is "'module' object has no > attribute 'decodestring'", Do you have your own base64.py (or base64.pyc) that's shadowing the standard module base64? Try this: >>

help me~!about base64

2008-12-02 Thread ylj798
my code: − import base64 def deflashget(st): if st.startswith('Flashget://'): return base64.decodestring(st[len('Flashget://'):])[10:-10] elif st.startswith('http://') or st.startswith('ftp://')

Re: base64.urlsafe_b64encode and the equal character

2008-03-28 Thread Clodoaldo
, the output has > >> 4*(n+1) chars right padded with 2 or 1 "=" chars. > >> If your input has 3n chars, the output won't have any "=" > > > Thanks. But I'm not sure i get it. What is n? > > (Any nonnegative integer...) > I mean: For base64

Re: base64.urlsafe_b64encode and the equal character

2008-03-28 Thread Gabriel Genellina
t;> >> Only at the end. The encoded string has 4*n chars when the input string >> has 3*n chars; when the input length is 3*n+1 or 3*n+2, the output has >> 4*(n+1) chars right padded with 2 or 1 "=" chars. >> If your input has 3n chars, the output won't have

Re: base64.urlsafe_b64encode and the equal character

2008-03-28 Thread Clodoaldo
On Mar 28, 12:09 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 28 Mar 2008 10:54:49 -0300, Clodoaldo <[EMAIL PROTECTED]> > escribió: > > > > > I'm using a md5 hash encoded with base64.urlsafe_b64encode as a > > parameter of

Re: base64.urlsafe_b64encode and the equal character

2008-03-28 Thread Gabriel Genellina
En Fri, 28 Mar 2008 10:54:49 -0300, Clodoaldo <[EMAIL PROTECTED]> escribió: > I'm using a md5 hash encoded with base64.urlsafe_b64encode as a > parameter of a URL used to confirm a registration in a site. It has > been working great. > > The url is like this: > &g

base64.urlsafe_b64encode and the equal character

2008-03-28 Thread Clodoaldo
I'm using a md5 hash encoded with base64.urlsafe_b64encode as a parameter of a URL used to confirm a registration in a site. It has been working great. The url is like this: http://example.com/ce?i=878&h=kTfWSUaby5sBu9bIfoR87Q== Now i need to match that URL in a certain text and i real

Send file in base64

2007-12-04 Thread Jose Ignacio Gisbert
Hi all, I need to send a file to a server using xmlrpc api. The receiver must get file data in base64 type, and what I do is: openfilename=tkFileDialog.askopenfilename(filetypes=[("all files", "*")]) f=open(tlocald.get(),'r') functionsend(xmlrpclib.Binary(f

Re: Error on base64.b64decode() ?!

2007-10-14 Thread Tim Roberts
=". If it >> still doesn't work, then you might be out of luck. > >This seems to work in some cases, but not all. Whats the deal with >this adding of "="? Is there an implementation error in python, or are >other implemenations of base64 more robust then they have

Re: Error on base64.b64decode() ?!

2007-10-13 Thread Christoph Krammer
out of luck. This seems to work in some cases, but not all. Whats the deal with this adding of "="? Is there an implementation error in python, or are other implemenations of base64 more robust then they have to be? Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Error on base64.b64decode() ?!

2007-10-12 Thread Jean-Paul Calderone
decode the image and save it to a >database: > >try: > imagedec = base64.b64decode(imageenc) > imagehash = md5.new(imagedec).hexdigest() > dbcurs.execute() >except TypeError, e: > print "Error '%s' in Message %s" % (e, dbrow[1]) > print im

Error on base64.b64decode() ?!

2007-10-12 Thread Christoph Krammer
Hello everybody, I am using a python script to extract images from email messages. This works fine for some messages, but not all attached images can be decoded. I use the following code to decode the image and save it to a database: try: imagedec = base64.b64decode(imageenc) imagehash = md5

Re: Need Help with base64

2007-07-23 Thread Tim Roberts
pycraze <[EMAIL PROTECTED]> wrote: > >int base641_decodestring(char* pcstr,int size,char** ppcdest) >{ > unsigned char cin[4] = {""}; > unsigned char cout[3] = {""}; > unsigned char cv = 0; > int ni = 0; > int nlen = 0; > char* cptr = pcstr; > *ppcdest = malloc(sizeof(ch

Re: Need Help with base64

2007-07-23 Thread Terry Reedy
"pycraze" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hi , | | I am currently trying to implement base64 encoding and decoding | scheme in C . Python has a module , base64 , that will do the | encoding and decoding with ease . I am aware of OpenSSL having supp

Re: Need Help with base64

2007-07-23 Thread Diez B. Roggisch
pycraze wrote: > Hi , > > I am currently trying to implement base64 encoding and decoding > scheme in C . Python has a module , base64 , that will do the > encoding and decoding with ease . I am aware of OpenSSL having support > for base64 encoding and decoding , but

Need Help with base64

2007-07-23 Thread pycraze
Hi , I am currently trying to implement base64 encoding and decoding scheme in C . Python has a module , base64 , that will do the encoding and decoding with ease . I am aware of OpenSSL having support for base64 encoding and decoding , but i will have to now implement both in C without using

Re: base64 and unicode

2007-05-04 Thread Duncan Booth
EuGeNe Van den Bulke <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: >> However, the decoded text looks as though it is utf16 encoded so it >> should be written as binary. i.e. the output mode should be "wb". > > Thanks for the "wb" tip that works (see bellow). I guess it is > experience based

Re: base64 and unicode

2007-05-04 Thread EuGeNe Van den Bulke
ell that it was utf16 encoded? > Simpler than using the base64 module you can just use the base64 codec. > This will decode a string to a byte sequence and you can then decode that > to get the unicode string: > > with file("hebrew.b64","r") as f: >text = f.

Re: base64 and unicode

2007-05-04 Thread Duncan Booth
EuGeNe Van den Bulke <[EMAIL PROTECTED]> wrote: > >>> import base64 > >>> base64.decode(file("hebrew.b64","r"),file("hebrew.lang","w")) > > It runs but the result is not correct: some of the lines in hebrew.lang > a

base64 and unicode

2007-05-04 Thread EuGeNe Van den Bulke
Hi, I am trying to convert the file hebrew.b64 attached into hebrew.lang (text file usable by Inline Search <http://www.ieforge.com/InlineSearch> for localization purposes. >>> import base64 >>> base64.decode(file("hebrew.b64","r"),file("

Re: using methods base64 module in conjunction with Crypto.Hash.SHA256

2006-12-20 Thread Klaas
e value labeled 'Shared key' is the 44 > characters within the quotes: > '6lfg2JWdrIR4qkejML0e3YtN4XevHvqowDCDu6XQEFc=' I doubt it. That is a base64 encoded value, not the value itself. <> > My interpretation of the first example is this: when you use an

using methods base64 module in conjunction with Crypto.Hash.SHA256

2006-12-19 Thread mirandacascade
the 44 characters within the quotes: '6lfg2JWdrIR4qkejML0e3YtN4XevHvqowDCDu6XQEFc=' and the value labeled 'Base64 Message Hash' is the 44 characters within the quotes: 'KF7GkfXkgXFNOgeRud58Oqx2equmKACAwzqQHZnZx9A=' In the second example, the value labeled 'Shared key' is the 44 character

Re: wxPython: Icon aus base64 decoded Image

2006-12-11 Thread Bjoern Schliessmann
Roland Rickborn wrote: > Wo ist der Fehler und was muss ich machen, damit das Icon > angezeigt wird? I'm sorry that I can't help you, but you'll probably get more answers if you write again in English (this is comp.lang.python). Grüße, Björn -- BOFH excuse #126: it has Intel Inside -- htt

wxPython: Icon aus base64 decoded Image

2006-12-11 Thread Roland Rickborn
Hallo zusammen, in meine Anwendung ist ein Bild eingebettet und oben in der Leiste soll ein Icon erscheinen. Ausserdem will ich nur _eine_ Datei ausgeben, also ohne zusärtliche Bild-Dateien etc. Dazu habe ich das Bild in base64 codiert und als String im Skript gespeichert, siehe unten. Beim

Re: How to convert arbitrary objects directly to base64 without initial string conversion?

2006-07-13 Thread Stefan Behnel
Russell Warren wrote: > How can you tell what objects support the buffer interface? Is > anything visible at the python level, or do you need to dig into the C > source? At the C level, there is a function for testing: int PyObject_CheckReadBuffer(PyObject* o) http://docs.python.org/dev/api/abs

Re: How to convert arbitrary objects directly to base64 without initial string conversion?

2006-07-13 Thread Russell Warren
After some digging around it appears there is not a tonne of documentation on buffer objects, although they are clearly core and ancient... been sifting through some hits circa 1999, long before my python introduction. What I can find says that buffer is deprecated (Python in a Nutshell), or non-e

Re: How to convert arbitrary objects directly to base64 without initial string conversion?

2006-07-13 Thread Russell Warren
> Many functions that operate on strings also accept buffer objects as > parameters, > this seems also be the case for the base64.encodestring function. ctypes > objects > support the buffer interface. > > So, base64.b64encode(buffer(ctypes_instance)) should work efficien

Re: How to convert arbitrary objects directly to base64 without initial string conversion?

2006-07-13 Thread Thomas Heller
Russell Warren schrieb: > I've got a case where I want to convert binary blocks of data (various > ctypes objects) to base64 strings. > > The conversion calls in the base64 module expect strings as input, so > right now I'm converting the binary blocks to strings fir

How to convert arbitrary objects directly to base64 without initial string conversion?

2006-07-13 Thread Russell Warren
I've got a case where I want to convert binary blocks of data (various ctypes objects) to base64 strings. The conversion calls in the base64 module expect strings as input, so right now I'm converting the binary blocks to strings first, then converting the resulting string to base64.

Re: base64

2006-04-13 Thread Jay
nd is splitting up words and splitting at a pacific caricature, I can not see how you split after a number of caricatures ...START.. from Tkinter import * from base64 i

  1   2   >