Skip to content

Instantly share code, notes, and snippets.

@gschizas
Created August 27, 2014 07:20
Show Gist options
  • Save gschizas/678132e045681395eafa to your computer and use it in GitHub Desktop.
Save gschizas/678132e045681395eafa to your computer and use it in GitHub Desktop.
#!/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")
@jomo
Copy link

jomo commented Nov 5, 2014

You could just check if the last character is % 2 == 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment