Created
August 27, 2014 07:20
-
-
Save gschizas/678132e045681395eafa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
import requests | |
import struct | |
import uuid | |
def java_uuid_hash_code(uuid): | |
leastSigBits, mostSigBits = struct.unpack('>QQ', uuid.bytes) | |
l1 = leastSigBits & 0xFFFFFFFF | |
l2 = (leastSigBits & 0xFFFFFFFF00000000) >> 32 | |
m1 = mostSigBits & 0xFFFFFFFF | |
m2 = (mostSigBits & 0xFFFFFFFF00000000) >> 32 | |
return (l1 ^ l2) ^ (m1 ^ m2) | |
username = sys.argv[1] | |
profile_info = requests.get('https://api.mojang.com/users/profiles/minecraft/' + username).json() | |
profile_id = uuid.UUID(profile_info['id']) | |
profile_hash = java_uuid_hash_code(profile_id) | |
if profile_hash % 2 == 0: | |
print("You're a Steve") | |
else: | |
print("You're an Alex") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could just check if the last character is % 2 == 0