def urlsafe_decrypt(key, ciphertext):
 ciphertext = base64.urlsafe_b64decode(str(ciphertext))
 cypher = AES.new(key, AES.MODE_CBC, ciphertext[:16])
 padded = cypher.decrypt(ciphertext[16:])
 return padded[:padded.rfind(chr(0))]

def urlsafe_decrypt ( key , ciphertext ) : ciphertext = base64 . urlsafe_b64decode ( str ( ciphertext ) ) cypher = AES . new ( key , AES . MODE_CBC , ciphertext [ : 16 ] ) padded = cypher . decrypt ( ciphertext [ 16 : ] ) return padded [ : padded . rfind ( chr ( 0 ) ) ]
decrypts url-safe base64 encoded ciphertext .