def b32encode(s):
parts = []<EOL>quanta, leftover = divmod(len(s), <NUM_LIT:5>)<EOL>if leftover:<EOL><INDENT>s += ('<STR_LIT>' * (<NUM_LIT:5> - leftover))<EOL>quanta += <NUM_LIT:1><EOL><DEDENT>for i in range(quanta):<EOL><INDENT>c1, c2, c3 = struct.unpack('<STR_LIT>', s[i*<NUM_LIT:5>:(i+<NUM_LIT:1>)*<NUM_LIT:5>])<EOL>c2 += (c1 & <NUM_LIT:1>) << <NUM_LIT:16> <EOL>c3 += (c2 & <NUM_LIT:3>) << <NUM_LIT:8>  <EOL>parts.extend([_b32tab[c1 >> <NUM_LIT:11>],         <EOL>_b32tab[(c1 >> <NUM_LIT:6>) & <NUM_LIT>], <EOL>_b32tab[(c1 >> <NUM_LIT:1>) & <NUM_LIT>], <EOL>_b32tab[c2 >> <NUM_LIT:12>],         <EOL>_b32tab[(c2 >> <NUM_LIT:7>) & <NUM_LIT>], <EOL>_b32tab[(c2 >> <NUM_LIT:2>) & <NUM_LIT>], <EOL>_b32tab[c3 >> <NUM_LIT:5>],          <EOL>_b32tab[c3 & <NUM_LIT>],        <EOL>])<EOL><DEDENT>encoded = EMPTYSTRING.join(parts)<EOL>if leftover == <NUM_LIT:1>:<EOL><INDENT>return encoded[:-<NUM_LIT:6>] + '<STR_LIT>'<EOL><DEDENT>elif leftover == <NUM_LIT:2>:<EOL><INDENT>return encoded[:-<NUM_LIT:4>] + '<STR_LIT>'<EOL><DEDENT>elif leftover == <NUM_LIT:3>:<EOL><INDENT>return encoded[:-<NUM_LIT:3>] + '<STR_LIT>'<EOL><DEDENT>elif leftover == <NUM_LIT:4>:<EOL><INDENT>return encoded[:-<NUM_LIT:1>] + '<STR_LIT:=>'<EOL><DEDENT>return encoded<EOL>
Encode a string using Base32.

    s is the string to encode.  The encoded string is returned.