def get_symkey(link): md5 = hashlib.md5() md5.update(link.encode("utf-8")) return base64.b16encode(md5.digest()).decode("utf-8") # this pattern matches substrings of reserved and non-ASCII characters