def aws_to_unix_id ( aws_key_id ) : uid_bytes = hashlib . sha256 ( aws_key_id . encode ( ) ) . digest ( ) [ - 2 : ] if USING_PYTHON2 : return 2000 + int ( from_bytes ( uid_bytes ) // 2 ) else : return 2000 + ( int . from_bytes ( uid_bytes , byteorder = sys . byteorder ) // 2 )
how to covert string to 128 bit lenght key in python
Converts a AWS Key ID into a UID
def aws_to_unix_id(aws_key_id):
    """Converts a AWS Key ID into a UID"""
    uid_bytes = hashlib.sha256(aws_key_id.encode()).digest()[-2:]
    if USING_PYTHON2:
        return 2000 + int(from_bytes(uid_bytes) // 2)
    else:
        return 2000 + (int.from_bytes(uid_bytes, byteorder=sys.byteorder) // 2)