[ python-Bugs-1170331 ] Error in base64.b32decode

SourceForge.net noreply at sourceforge.net
Fri Mar 25 05:05:55 CET 2005


Bugs item #1170331, was opened at 2005-03-25 05:05
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1170331&group_id=5470

Category: Extension Modules
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: toidinamai (toidinamai)
Assigned to: Nobody/Anonymous (nobody)
Summary: Error in base64.b32decode

Initial Comment:
Hi,                                                   
                                                      
                                                         
                                                      
                                                      
                                                         
I believe there is an error in base64.b32decode because
it doesn't seem to                                    
                                                          
allow to decode arbitrary binary data:                
                                                      
                                                         

<code>                                                
                                                      
                                                         
#!/usr/bin/env python2.4                              
                                                      
                                                         
                                                      
                                                      
                                                         
import base64                                         
                                                      
                                                         
                                                      
                                                      
                                                         
b64d = base64.b64decode                               
                                                      
                                                         
b64e = base64.b64encode                               
                                                      
                                                         
                                                      
                                                      
                                                         
print "base64: ", repr(b64d(b64e('\x00')))            
                                                      
                                                         
                                                      
                                                      
                                                         
b16d = base64.b16decode                               
                                                      
                                                         
b16e = base64.b16encode                               
                                                      
                                                         
                                                      
                                                      
                                                         
print "base16: ", repr(b16d(b16e('\x00')))            
                                                      
                                                         
                                                      
                                                      
                                                         
b32d = base64.b32decode                               
                                                      
                                                         
b32e = base64.b32encode                               
                                                      
                                                         
                                                      
                                                      
                                                         
print "base32: ", repr(b32d(b32e('\x00')))            
                                                      
                                                         
</code>                                               
                                                      
                                                         
                                                      
                                                      
                                                         
This raises a very strange exception:                 
                                                      
                                                         
                                                      
                                                      
                                                         
Traceback (most recent call last):                    
                                                      
                                                         
  File "test.py", line 18, in ?                       
                                                      
                                                         
    print "base32: ", repr(b32d(b32e('\x00')))        
                                                      
                                                         
  File "/usr/lib/python2.4/base64.py", line 228, in
b32decode                                             
                                                      
     
    last = binascii.unhexlify(hex(acc)[2:-1])         
                                                      
                                                         
TypeError: Odd-length string                          
                                                      
                                                         
                                                      
                                                      
                                                         
b32 should work just like b64 and b16.                
                                                      
                                                      
                                                      
                                                      
                                            

Best regards
Frank Bensktein.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1170331&group_id=5470


More information about the Python-bugs-list mailing list