Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- from base64 import b64decode
- def build_id(pub_key_pem):
- pub_key_der = b64decode(pub_key_pem)
- sha = hashlib.sha256(pub_key_der).hexdigest()
- prefix = sha[:32]
- reencoded = ""
- ord_a = ord('a')
- for old_char in prefix:
- code = int(old_char, 16)
- new_char = chr(ord_a + code)
- reencoded += new_char
- return reencoded
- def main():
- pub_key = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCjvF5pjuK8gRaw/2LoRYi37QqRd48B/FeO9yFtT6ueY84z/u0NrJ/xbPFc9OCGBi8RKIblVvcbY0ySGqdmp0QsUr/oXN0b06GL4iB8rMhlO082HhMzrClV8OKRJ+eJNhNBl8viwmtJs3MN0x9ljA4HQLaAPBA9a14IUKLjP0pWuwIDAQAB'
- id_ = build_id(pub_key)
- print(id_)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement