[ {"type":"CommentHashbang","value":"#! /usr/bin/env python"}, {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# From CPython (Lib/base64.py)"}, {"type":"Text","value":"\n\n"}, {"type":"LiteralStringDouble","value":"\"\"\"RFC 3548: Base16, Base32, Base64 Data Encodings\"\"\""}, {"type":"Text","value":"\n\n"}, {"type":"CommentSingle","value":"# Modified 04-Oct-1995 by Jack Jansen to use binascii module"}, {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# Modified 30-Dec-2003 by Barry Warsaw to add full RFC 3548 support"}, {"type":"Text","value":"\n\n"}, {"type":"KeywordNamespace","value":"import"}, {"type":"Text","value":" "}, {"type":"NameNamespace","value":"re"}, {"type":"Text","value":"\n"}, {"type":"KeywordNamespace","value":"import"}, {"type":"Text","value":" "}, {"type":"NameNamespace","value":"struct"}, {"type":"Text","value":"\n"}, {"type":"KeywordNamespace","value":"import"}, {"type":"Text","value":" "}, {"type":"NameNamespace","value":"string"}, {"type":"Text","value":"\n"}, {"type":"KeywordNamespace","value":"import"}, {"type":"Text","value":" "}, {"type":"NameNamespace","value":"binascii"}, {"type":"Text","value":"\n\n\n"}, {"type":"Name","value":"__all__"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"["}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Legacy interface exports traditional RFC 1521 Base64 encodings"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringSingle","value":"'encode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'decode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'encodestring'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'decodestring'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Generalized interface for other encodings"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringSingle","value":"'b64encode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'b64decode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'b32encode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'b32decode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralStringSingle","value":"'b16encode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'b16decode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Standard Base64 encoding"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringSingle","value":"'standard_b64encode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'standard_b64decode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Some common Base64 alternatives. As referenced by RFC 3458, see thread"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# starting at:"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"#"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# http://zgp.org/pipermail/p2p-hackers/2001-September/000316.html"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringSingle","value":"'urlsafe_b64encode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'urlsafe_b64decode'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n\n"}, {"type":"Name","value":"_translation"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"["}, {"type":"NameBuiltin","value":"chr"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"_x"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"_x"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"range"}, {"type":"Punctuation","value":"("}, {"type":"LiteralNumberInteger","value":"256"}, {"type":"Punctuation","value":")]"}, {"type":"Text","value":"\n"}, {"type":"Name","value":"EMPTYSTRING"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"''"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"_translate"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"altchars"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"translation"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"_translation"}, {"type":"Punctuation","value":"[:]"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"k"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"v"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"Name","value":"altchars"}, {"type":"Operator","value":"."}, {"type":"Name","value":"items"}, {"type":"Punctuation","value":"():"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"translation"}, {"type":"Punctuation","value":"["}, {"type":"NameBuiltin","value":"ord"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"k"}, {"type":"Punctuation","value":")]"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"v"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Operator","value":"."}, {"type":"Name","value":"translate"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"''"}, {"type":"Operator","value":"."}, {"type":"Name","value":"join"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"translation"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n\n\n\u000c\n"}, {"type":"CommentSingle","value":"# Base64 encoding/decoding uses binascii"}, {"type":"Text","value":"\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"b64encode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"altchars"}, {"type":"Operator","value":"="}, {"type":"NameBuiltinPseudo","value":"None"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Encode a string using Base64.\n\n s is the string to encode. Optional altchars must be a string of at least\n length 2 (additional characters are ignored) which specifies an\n alternative alphabet for the '+' and '/' characters. This allows an\n application to e.g. generate url or filesystem safe Base64 strings.\n\n The encoded string is returned.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Strip off the trailing newline"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"encoded"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"b2a_base64"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"altchars"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"is"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"not"}, {"type":"Text","value":" "}, {"type":"NameBuiltinPseudo","value":"None"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"encoded"}, {"type":"Operator","value":"."}, {"type":"Name","value":"translate"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"string"}, {"type":"Operator","value":"."}, {"type":"Name","value":"maketrans"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringAffix","value":"b"}, {"type":"LiteralStringSingle","value":"'+/'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"altchars"}, {"type":"Punctuation","value":"[:"}, {"type":"LiteralNumberInteger","value":"2"}, {"type":"Punctuation","value":"]))"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"encoded"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"b64decode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"altchars"}, {"type":"Operator","value":"="}, {"type":"NameBuiltinPseudo","value":"None"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Decode a Base64 encoded string.\n\n s is the string to decode. Optional altchars must be a string of at least\n length 2 (additional characters are ignored) which specifies the\n alternative alphabet used instead of the '+' and '/' characters.\n\n The decoded string is returned. A TypeError is raised if s is\n incorrectly padded. Characters that are neither in the normal base-64\n alphabet nor the alternative alphabet are discarded prior to the padding\n check.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"altchars"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"is"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"not"}, {"type":"Text","value":" "}, {"type":"NameBuiltinPseudo","value":"None"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Operator","value":"."}, {"type":"Name","value":"translate"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"string"}, {"type":"Operator","value":"."}, {"type":"Name","value":"maketrans"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"altchars"}, {"type":"Punctuation","value":"[:"}, {"type":"LiteralNumberInteger","value":"2"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'+/'"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"try"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"a2b_base64"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"except"}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"Error"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"msg"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Transform this exception for consistency"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"raise"}, {"type":"Text","value":" "}, {"type":"NameException","value":"TypeError"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"msg"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"standard_b64encode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Encode a string using the standard Base64 alphabet.\n\n s is the string to encode. The encoded string is returned.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"b64encode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"standard_b64decode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Decode a string encoded with the standard Base64 alphabet.\n\n Argument s is the string to decode. The decoded string is returned. A\n TypeError is raised if the string is incorrectly padded. Characters that\n are not in the standard alphabet are discarded prior to the padding\n check.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"b64decode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n"}, {"type":"Name","value":"_urlsafe_encode_translation"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"string"}, {"type":"Operator","value":"."}, {"type":"Name","value":"maketrans"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringAffix","value":"b"}, {"type":"LiteralStringSingle","value":"'+/'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringAffix","value":"b"}, {"type":"LiteralStringSingle","value":"'-_'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n"}, {"type":"Name","value":"_urlsafe_decode_translation"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"string"}, {"type":"Operator","value":"."}, {"type":"Name","value":"maketrans"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringAffix","value":"b"}, {"type":"LiteralStringSingle","value":"'-_'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringAffix","value":"b"}, {"type":"LiteralStringSingle","value":"'+/'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"urlsafe_b64encode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Encode a string using the URL- and filesystem-safe Base64 alphabet.\n\n Argument s is the string to encode. The encoded string is returned. The\n alphabet uses '-' instead of '+' and '_' instead of '/'.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"b64encode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Operator","value":"."}, {"type":"Name","value":"translate"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"_urlsafe_encode_translation"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"urlsafe_b64decode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Decode a string using the URL- and filesystem-safe Base64 alphabet.\n\n Argument s is the string to decode. The decoded string is returned. A\n TypeError is raised if the string is incorrectly padded. Characters that\n are not in the URL-safe base-64 alphabet, and are not a plus '+' or slash\n '/', are discarded prior to the padding check.\n\n The alphabet uses '-' instead of '+' and '_' instead of '/'.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"b64decode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Operator","value":"."}, {"type":"Name","value":"translate"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"_urlsafe_decode_translation"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n\n\n\u000c\n"}, {"type":"CommentSingle","value":"# Base32 encoding/decoding must be done in Python"}, {"type":"Text","value":"\n"}, {"type":"Name","value":"_b32alphabet"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"{"}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'A'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"9"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'J'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"18"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'S'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"27"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'3'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'B'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"10"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'K'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"19"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'T'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"28"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'4'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"2"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'C'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"11"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'L'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"20"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'U'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"29"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'5'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"3"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'D'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"12"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'M'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"21"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'V'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"30"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'6'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"4"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'E'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"13"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'N'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"22"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'W'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"31"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'7'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"5"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'F'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"14"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'O'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"23"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'X'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"6"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'G'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"15"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'P'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"24"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'Y'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"7"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'H'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"16"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'Q'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"25"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'Z'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"LiteralNumberInteger","value":"8"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'I'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"17"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'R'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"26"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'2'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":"\n "}, {"type":"Punctuation","value":"}"}, {"type":"Text","value":"\n\n"}, {"type":"Name","value":"_b32tab"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"_b32alphabet"}, {"type":"Operator","value":"."}, {"type":"Name","value":"items"}, {"type":"Punctuation","value":"()"}, {"type":"Text","value":"\n"}, {"type":"Name","value":"_b32tab"}, {"type":"Operator","value":"."}, {"type":"Name","value":"sort"}, {"type":"Punctuation","value":"()"}, {"type":"Text","value":"\n"}, {"type":"Name","value":"_b32tab"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"v"}, {"type":"Text","value":" "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"k"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"v"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n"}, {"type":"Name","value":"_b32rev"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"dict"}, {"type":"Punctuation","value":"([("}, {"type":"Name","value":"v"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"long"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"k"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":" "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"k"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"v"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"Name","value":"_b32alphabet"}, {"type":"Operator","value":"."}, {"type":"Name","value":"items"}, {"type":"Punctuation","value":"()])"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"b32encode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Encode a string using Base32.\n\n s is the string to encode. The encoded string is returned.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Name","value":"parts"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"[]"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"quanta"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"divmod"}, {"type":"Punctuation","value":"("}, {"type":"NameBuiltin","value":"len"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"),"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"5"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Pad the last quantum with zero bits if necessary"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'"}, {"type":"LiteralStringEscape","value":"\\0"}, {"type":"LiteralStringSingle","value":"'"}, {"type":"Text","value":" "}, {"type":"Operator","value":"*"}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"("}, {"type":"LiteralNumberInteger","value":"5"}, {"type":"Text","value":" "}, {"type":"Operator","value":"-"}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"quanta"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"i"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"range"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"quanta"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# c1 and c2 are 16 bits wide, c3 is 8 bits wide. The intent of this"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# code is to process the 40 bits in units of 5 bits. So we take the 1"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# leftover bit of c1 and tack it onto c2. Then we take the 2 leftover"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# bits of c2 and tack them onto c3. The shifts and masks are intended"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# to give us values of exactly 5 bits in width."}, {"type":"Text","value":"\n "}, {"type":"Name","value":"c1"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"c2"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"c3"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"struct"}, {"type":"Operator","value":"."}, {"type":"Name","value":"unpack"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'!HHB'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"i"}, {"type":"Operator","value":"*"}, {"type":"LiteralNumberInteger","value":"5"}, {"type":"Punctuation","value":":("}, {"type":"Name","value":"i"}, {"type":"Operator","value":"+"}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":")"}, {"type":"Operator","value":"*"}, {"type":"LiteralNumberInteger","value":"5"}, {"type":"Punctuation","value":"])"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"c2"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"c1"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u0026"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003c\u003c"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"16"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# 17 bits wide"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"c3"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"c2"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u0026"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"3"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003c\u003c"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"8"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# 10 bits wide"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"parts"}, {"type":"Operator","value":"."}, {"type":"Name","value":"extend"}, {"type":"Punctuation","value":"(["}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"c1"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"11"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 1 - 5"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"[("}, {"type":"Name","value":"c1"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"6"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u0026"}, {"type":"Text","value":" "}, {"type":"LiteralNumberHex","value":"0x1f"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 6 - 10"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"[("}, {"type":"Name","value":"c1"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u0026"}, {"type":"Text","value":" "}, {"type":"LiteralNumberHex","value":"0x1f"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 11 - 15"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"c2"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"12"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 16 - 20 (1 - 5)"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"[("}, {"type":"Name","value":"c2"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"7"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u0026"}, {"type":"Text","value":" "}, {"type":"LiteralNumberHex","value":"0x1f"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 21 - 25 (6 - 10)"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"[("}, {"type":"Name","value":"c2"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"2"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u0026"}, {"type":"Text","value":" "}, {"type":"LiteralNumberHex","value":"0x1f"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 26 - 30 (11 - 15)"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"c3"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"5"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 31 - 35 (1 - 5)"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"_b32tab"}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"c3"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u0026"}, {"type":"Text","value":" "}, {"type":"LiteralNumberHex","value":"0x1f"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# bits 36 - 40 (1 - 5)"}, {"type":"Text","value":"\n "}, {"type":"Punctuation","value":"])"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"encoded"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"EMPTYSTRING"}, {"type":"Operator","value":"."}, {"type":"Name","value":"join"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"parts"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Adjust for any leftover partial quanta"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"encoded"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"6"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'======'"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"elif"}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"2"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"encoded"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"4"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'===='"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"elif"}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"3"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"encoded"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"3"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'==='"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"elif"}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"4"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"encoded"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'='"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"encoded"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"b32decode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"casefold"}, {"type":"Operator","value":"="}, {"type":"NameBuiltinPseudo","value":"False"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"map01"}, {"type":"Operator","value":"="}, {"type":"NameBuiltinPseudo","value":"None"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Decode a Base32 encoded string.\n\n s is the string to decode. Optional casefold is a flag specifying whether\n a lowercase alphabet is acceptable as input. For security purposes, the\n default is False.\n\n RFC 3548 allows for optional mapping of the digit 0 (zero) to the letter O\n (oh), and for optional mapping of the digit 1 (one) to either the letter I\n (eye) or letter L (el). The optional argument map01 when not None,\n specifies which letter the digit 1 should be mapped to (when map01 is not\n None, the digit 0 is always mapped to the letter O). For security\n purposes the default is None, so that 0 and 1 are not allowed in the\n input.\n\n The decoded string is returned. A TypeError is raised if s were\n incorrectly padded or if there are non-alphabet characters present in the\n string.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Name","value":"quanta"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"divmod"}, {"type":"Punctuation","value":"("}, {"type":"NameBuiltin","value":"len"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"),"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"8"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"leftover"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"raise"}, {"type":"Text","value":" "}, {"type":"NameException","value":"TypeError"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'Incorrect padding'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Handle section 2.4 zero and one mapping. The flag map01 will be either"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# False, or the character to map the digit 1 (one) to. It should be"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# either L (el) or I (eye)."}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"map01"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Operator","value":"."}, {"type":"Name","value":"translate"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"string"}, {"type":"Operator","value":"."}, {"type":"Name","value":"maketrans"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringAffix","value":"b"}, {"type":"LiteralStringSingle","value":"'01'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"LiteralStringAffix","value":"b"}, {"type":"LiteralStringSingle","value":"'O'"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+"}, {"type":"Text","value":" "}, {"type":"Name","value":"map01"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"casefold"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Operator","value":"."}, {"type":"Name","value":"upper"}, {"type":"Punctuation","value":"()"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Strip off pad characters from the right. We need to count the pad"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# characters because this will tell us how many null bytes to remove from"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# the end of the decoded string."}, {"type":"Text","value":"\n "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"mo"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"re"}, {"type":"Operator","value":"."}, {"type":"Name","value":"search"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'(?P\u003cpad\u003e[=]*)$'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"mo"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"len"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"mo"}, {"type":"Operator","value":"."}, {"type":"Name","value":"group"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'pad'"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003e"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"Name","value":"padchars"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Now decode the full quanta"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"parts"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"[]"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"acc"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"shift"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"35"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"c"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"val"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"_b32rev"}, {"type":"Operator","value":"."}, {"type":"Name","value":"get"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"c"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"val"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"is"}, {"type":"Text","value":" "}, {"type":"NameBuiltinPseudo","value":"None"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"raise"}, {"type":"Text","value":" "}, {"type":"NameException","value":"TypeError"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'Non-base32 digit found'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"acc"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+="}, {"type":"Text","value":" "}, {"type":"Name","value":"_b32rev"}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"c"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003c\u003c"}, {"type":"Text","value":" "}, {"type":"Name","value":"shift"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"shift"}, {"type":"Text","value":" "}, {"type":"Operator","value":"-="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"5"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"shift"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003c"}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"parts"}, {"type":"Operator","value":"."}, {"type":"Name","value":"append"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"unhexlify"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'"}, {"type":"LiteralStringInterpol","value":"%010x"}, {"type":"LiteralStringSingle","value":"'"}, {"type":"Text","value":" "}, {"type":"Operator","value":"%"}, {"type":"Text","value":" "}, {"type":"Name","value":"acc"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"acc"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"shift"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"35"}, {"type":"Text","value":"\n "}, {"type":"CommentSingle","value":"# Process the last, partial quanta"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"last"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"unhexlify"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'"}, {"type":"LiteralStringInterpol","value":"%010x"}, {"type":"LiteralStringSingle","value":"'"}, {"type":"Text","value":" "}, {"type":"Operator","value":"%"}, {"type":"Text","value":" "}, {"type":"Name","value":"acc"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"last"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"''"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# No characters"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"elif"}, {"type":"Text","value":" "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"last"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"last"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"elif"}, {"type":"Text","value":" "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"3"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"last"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"last"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"2"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"elif"}, {"type":"Text","value":" "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"4"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"last"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"last"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"3"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"elif"}, {"type":"Text","value":" "}, {"type":"Name","value":"padchars"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"6"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"last"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"last"}, {"type":"Punctuation","value":"[:"}, {"type":"Operator","value":"-"}, {"type":"LiteralNumberInteger","value":"4"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"else"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"raise"}, {"type":"Text","value":" "}, {"type":"NameException","value":"TypeError"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'Incorrect padding'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"parts"}, {"type":"Operator","value":"."}, {"type":"Name","value":"append"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"last"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"EMPTYSTRING"}, {"type":"Operator","value":"."}, {"type":"Name","value":"join"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"parts"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n\u000c\n"}, {"type":"CommentSingle","value":"# RFC 3548, Base 16 Alphabet specifies uppercase, but hexlify() returns"}, {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# lowercase. The RFC also recommends against accepting input case"}, {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# insensitively."}, {"type":"Text","value":"\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"b16encode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Encode a string using Base16.\n\n s is the string to encode. The encoded string is returned.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"hexlify"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Operator","value":"."}, {"type":"Name","value":"upper"}, {"type":"Punctuation","value":"()"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"b16decode"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"casefold"}, {"type":"Operator","value":"="}, {"type":"NameBuiltinPseudo","value":"False"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Decode a Base16 encoded string.\n\n s is the string to decode. Optional casefold is a flag specifying whether\n a lowercase alphabet is acceptable as input. For security purposes, the\n default is False.\n\n The decoded string is returned. A TypeError is raised if s is\n incorrectly padded or if there are non-alphabet characters present in the\n string.\n \"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"casefold"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Operator","value":"."}, {"type":"Name","value":"upper"}, {"type":"Punctuation","value":"()"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"re"}, {"type":"Operator","value":"."}, {"type":"Name","value":"search"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'[^0-9A-F]'"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"raise"}, {"type":"Text","value":" "}, {"type":"NameException","value":"TypeError"}, {"type":"Punctuation","value":"("}, {"type":"LiteralStringSingle","value":"'Non-base16 digit found'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"unhexlify"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n\u000c\n"}, {"type":"CommentSingle","value":"# Legacy interface. This code could be cleaned up since I don't believe"}, {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# binascii has any line length limitations. It just doesn't seem worth it"}, {"type":"Text","value":"\n"}, {"type":"CommentSingle","value":"# though."}, {"type":"Text","value":"\n\n"}, {"type":"Name","value":"MAXLINESIZE"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralNumberInteger","value":"76"}, {"type":"Text","value":" "}, {"type":"CommentSingle","value":"# Excluding the CRLF"}, {"type":"Text","value":"\n"}, {"type":"Name","value":"MAXBINSIZE"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"MAXLINESIZE"}, {"type":"Operator","value":"//"}, {"type":"LiteralNumberInteger","value":"4"}, {"type":"Punctuation","value":")"}, {"type":"Operator","value":"*"}, {"type":"LiteralNumberInteger","value":"3"}, {"type":"Text","value":"\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"encode"}, {"type":"Punctuation","value":"("}, {"type":"NameBuiltin","value":"input"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"output"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Encode a file.\"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"while"}, {"type":"Text","value":" "}, {"type":"NameBuiltinPseudo","value":"True"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"input"}, {"type":"Operator","value":"."}, {"type":"Name","value":"read"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"MAXBINSIZE"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"not"}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"break"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"while"}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"len"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Operator","value":"\u003c"}, {"type":"Text","value":" "}, {"type":"Name","value":"MAXBINSIZE"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"ns"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"input"}, {"type":"Operator","value":"."}, {"type":"Name","value":"read"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"MAXBINSIZE"}, {"type":"Operator","value":"-"}, {"type":"NameBuiltin","value":"len"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"not"}, {"type":"Text","value":" "}, {"type":"Name","value":"ns"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"break"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+="}, {"type":"Text","value":" "}, {"type":"Name","value":"ns"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"line"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"b2a_base64"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"output"}, {"type":"Operator","value":"."}, {"type":"Name","value":"write"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"line"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"decode"}, {"type":"Punctuation","value":"("}, {"type":"NameBuiltin","value":"input"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"output"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Decode a file.\"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"while"}, {"type":"Text","value":" "}, {"type":"NameBuiltinPseudo","value":"True"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"line"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"input"}, {"type":"Operator","value":"."}, {"type":"Name","value":"readline"}, {"type":"Punctuation","value":"()"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"not"}, {"type":"Text","value":" "}, {"type":"Name","value":"line"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"break"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"a2b_base64"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"line"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"output"}, {"type":"Operator","value":"."}, {"type":"Name","value":"write"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"encodestring"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Encode a string into multiple lines of base-64 data.\"\"\""}, {"type":"Text","value":"\n "}, {"type":"Name","value":"pieces"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"[]"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"i"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"range"}, {"type":"Punctuation","value":"("}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"len"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"),"}, {"type":"Text","value":" "}, {"type":"Name","value":"MAXBINSIZE"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"chunk"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"["}, {"type":"Name","value":"i"}, {"type":"Text","value":" "}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"Name","value":"i"}, {"type":"Text","value":" "}, {"type":"Operator","value":"+"}, {"type":"Text","value":" "}, {"type":"Name","value":"MAXBINSIZE"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"pieces"}, {"type":"Operator","value":"."}, {"type":"Name","value":"append"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"b2a_base64"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"chunk"}, {"type":"Punctuation","value":"))"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"LiteralStringDouble","value":"\"\""}, {"type":"Operator","value":"."}, {"type":"Name","value":"join"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"pieces"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"decodestring"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":"):"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Decode a string.\"\"\""}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":" "}, {"type":"Name","value":"binascii"}, {"type":"Operator","value":"."}, {"type":"Name","value":"a2b_base64"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n\u000c\n"}, {"type":"CommentSingle","value":"# Useable as a script..."}, {"type":"Text","value":"\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"test"}, {"type":"Punctuation","value":"():"}, {"type":"Text","value":"\n "}, {"type":"LiteralStringDouble","value":"\"\"\"Small test program\"\"\""}, {"type":"Text","value":"\n "}, {"type":"KeywordNamespace","value":"import"}, {"type":"Text","value":" "}, {"type":"NameNamespace","value":"sys"}, {"type":"Operator","value":","}, {"type":"Text","value":" "}, {"type":"NameNamespace","value":"getopt"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"try"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"opts"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"args"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"getopt"}, {"type":"Operator","value":"."}, {"type":"Name","value":"getopt"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"argv"}, {"type":"Punctuation","value":"["}, {"type":"LiteralNumberInteger","value":"1"}, {"type":"Punctuation","value":":],"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'deut'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"except"}, {"type":"Text","value":" "}, {"type":"Name","value":"getopt"}, {"type":"Operator","value":"."}, {"type":"Name","value":"error"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"msg"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"stdout"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"stderr"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"print"}, {"type":"Text","value":" "}, {"type":"Name","value":"msg"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"print"}, {"type":"Text","value":" "}, {"type":"LiteralStringDouble","value":"\"\"\"usage: "}, {"type":"LiteralStringInterpol","value":"%s"}, {"type":"LiteralStringDouble","value":" [-d|-e|-u|-t] [file|-]\n -d, -u: decode\n -e: encode (default)\n -t: encode and decode string 'Aladdin:open sesame'\"\"\""}, {"type":"Operator","value":"%"}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"argv"}, {"type":"Punctuation","value":"["}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"exit"}, {"type":"Punctuation","value":"("}, {"type":"LiteralNumberInteger","value":"2"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"func"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"encode"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"for"}, {"type":"Text","value":" "}, {"type":"Name","value":"o"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"a"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"in"}, {"type":"Text","value":" "}, {"type":"Name","value":"opts"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"o"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'-e'"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"Name","value":"func"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"encode"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"o"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'-d'"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"Name","value":"func"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"decode"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"o"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'-u'"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"Name","value":"func"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"decode"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"o"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'-t'"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":" "}, {"type":"Name","value":"test1"}, {"type":"Punctuation","value":"();"}, {"type":"Text","value":" "}, {"type":"Keyword","value":"return"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"Name","value":"args"}, {"type":"Text","value":" "}, {"type":"OperatorWord","value":"and"}, {"type":"Text","value":" "}, {"type":"Name","value":"args"}, {"type":"Punctuation","value":"["}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":"]"}, {"type":"Text","value":" "}, {"type":"Operator","value":"!="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'-'"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"with"}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"open"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"args"}, {"type":"Punctuation","value":"["}, {"type":"LiteralNumberInteger","value":"0"}, {"type":"Punctuation","value":"],"}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'rb'"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":" "}, {"type":"Keyword","value":"as"}, {"type":"Text","value":" "}, {"type":"Name","value":"f"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"func"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"f"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"stdout"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"else"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"func"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"stdin"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"Name","value":"sys"}, {"type":"Operator","value":"."}, {"type":"Name","value":"stdout"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"def"}, {"type":"Text","value":" "}, {"type":"NameFunction","value":"test1"}, {"type":"Punctuation","value":"():"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s0"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"LiteralStringDouble","value":"\"Aladdin:open sesame\""}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s1"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"encodestring"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s0"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"s2"}, {"type":"Text","value":" "}, {"type":"Operator","value":"="}, {"type":"Text","value":" "}, {"type":"Name","value":"decodestring"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s1"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n "}, {"type":"Keyword","value":"print"}, {"type":"Text","value":" "}, {"type":"Name","value":"s0"}, {"type":"Punctuation","value":","}, {"type":"Text","value":" "}, {"type":"NameBuiltin","value":"repr"}, {"type":"Punctuation","value":"("}, {"type":"Name","value":"s1"}, {"type":"Punctuation","value":"),"}, {"type":"Text","value":" "}, {"type":"Name","value":"s2"}, {"type":"Text","value":"\n\n\n"}, {"type":"Keyword","value":"if"}, {"type":"Text","value":" "}, {"type":"NameVariableMagic","value":"__name__"}, {"type":"Text","value":" "}, {"type":"Operator","value":"=="}, {"type":"Text","value":" "}, {"type":"LiteralStringSingle","value":"'__main__'"}, {"type":"Punctuation","value":":"}, {"type":"Text","value":"\n "}, {"type":"Name","value":"test"}, {"type":"Punctuation","value":"()"}, {"type":"Text","value":"\n"} ]