<s> import base64 <EOL> from binascii import Error as BinasciiError <EOL> try : <EOL> from django . utils . http import urlsafe_base64_encode <EOL> except ImportError : <EOL> def urlsafe_base64_encode ( s ) : <EOL> """<STR_LIT>""" <EOL> return base64 . urlsafe_b64encode ( s ) . rstrip ( b'<STR_LIT>' ) <EOL> try : <EOL> from django . utils . http import urlsafe_base64_decode <EOL> except ImportError : <EOL> def urlsafe_base64_decode ( s ) : <EOL> """<STR_LIT>""" <EOL> s = s . encode ( '<STR_LIT:utf-8>' ) <EOL> try : <EOL> return base64 . urlsafe_b64decode ( s . ljust ( len ( s ) + len ( s ) % <NUM_LIT:4> , b'<STR_LIT:=>' ) ) <EOL> except ( LookupError , BinasciiError ) as e : <EOL> raise ValueError ( e ) </s>
