Xorn
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Functions | Variables
xorn.base64 Namespace Reference

Reading and writing base64-encoded data. More...

Classes

class  DecodingError
 Raised when reading invalid or unterminated base64-encoded data. More...
 

Functions

def encode
 Write a binary string to a file in base64 representation. More...
 
def decode
 Read a string in base64 representation from a file. More...
 

Variables

string BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
 
string PAD64 = '='
 
list RANK
 

Detailed Description

Reading and writing base64-encoded data.

Function Documentation

def xorn.base64.decode (   f,
  delim = None 
)

Read a string in base64 representation from a file.

This function is liberal in what it will accept. It ignores non-base64 symbols.

If delim is None, read until the end of the file. If delim is not None, read until a line containing exactly delim is found.

Returns
A string containing the decoded data.
Exceptions
DecodingErrorif reading something that is not valid base64-encoded data
DecodingErrorif the end of the file is hit and delim is not None

Definition at line 138 of file base64.py.

def xorn.base64.encode (   f,
  src,
  columns = 72,
  delim = None 
)

Write a binary string to a file in base64 representation.

If columns is not None, insert a newline every columns characters. This is required by RFC 2045, but some applications don't require it. columns must positive and a multiple of 4.

If delim is not None, it is written on a separate line after the data. This argument is provided for symmetry with decode.

Returns
None.

Definition at line 68 of file base64.py.

Variable Documentation

string xorn.base64.BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'

Definition at line 36 of file base64.py.

string xorn.base64.PAD64 = '='

Definition at line 37 of file base64.py.

list xorn.base64.RANK
Initial value:
1 = [
2  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0x00-0x0f
3  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0x10-0x1f
4  255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63, # 0x20-0x2f
5  52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255,255,255,255, # 0x30-0x3f
6  255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, # 0x40-0x4f
7  15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255, # 0x50-0x5f
8  255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, # 0x60-0x6f
9  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255, # 0x70-0x7f
10  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0x80-0x8f
11  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0x90-0x9f
12  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0xa0-0xaf
13  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0xb0-0xbf
14  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0xc0-0xcf
15  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0xd0-0xdf
16  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0xe0-0xef
17  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 0xf0-0xff
18 ]

Definition at line 38 of file base64.py.