<commit_before># -*- coding: utf-8 -*-
"""
python-bna
Battle.net Authenticator routines in Python.

Specification can be found here:
  <http://bnetauth.freeportal.us/specification.html>
Python implementation by <NAME> <<EMAIL>>
"""
from time import time
from hashlib import sha1

RSA_KEY = 104890018807986556874007710914205443157030159668034197186125678960287470894290830530618284943118405110896322835449099433232093151168250152146023319326491587651685252774820340995950744075665455681760652136576493028733914892166700899109836291180881063097461175643998356321993663868233366705340758102567742483097
RSA_MOD = 257

ENROLL_HOSTS = {
	#"EU": "m.eu.mobileservice.blizzard.com",
	#"US": "m.us.mobileservice.blizzard.com",
	"EU": "eu.mobile-service.blizzard.com",
	"US": "us.mobile-service.blizzard.com",
	"default": "mobile-service.blizzard.<EMAIL>",
}

def getEmptyEncryptMsg(otp, region, model):
	ret = (otp + "\0" * 37)[:37]
	ret += region or "\0\0"
	ret += (model + "\0" * 16)[:16]
	return chr(1) + ret

def doEnroll(data, enroll_host=ENROLL_HOSTS["default"], enroll_uri="/enrollment/enroll.htm"):
	"""
	Send computed data to Blizzard servers
	Return the answer from the server
	"""
	from httplib import HTTPConnection
	
	conn = HTTPConnection(enroll_host)
	conn.request("POST", enroll_uri, data)
	response = conn.getresponse()
	
	if response.status != 200:
		raise IOError("%s returned status %i" % (enroll_host, response.status))
	
	ret = response.read()
	conn.close()
	return ret

def encrypt(data):
	data = int(data.encode("hex"), 16)
	n = data ** RSA_MOD % RSA_KEY
	ret = ""
	while n > 0:<commit_msg>bna: Raise a custom HTTPError exception if the server sends the wrong http status<commit_after># -*- coding: utf-8 -*-
"""
python-bna
Battle.net Authenticator routines in Python.

Specification can be found here:
  <http://bnetauth.freeportal.us/specification.html>
Python implementation by <NAME> <<EMAIL>>
"""
from time import time
from hashlib import sha1

RSA_KEY = 104890018807986556874007710914205443157030159668034197186125678960287470894290830530618284943118405110896322835449099433232093151168250152146023319326491587651685252774820340995950744075665455681760652136576493028733914892166700899109836291180881063097461175643998356321993663868233366705340758102567742483097
RSA_MOD = 257

ENROLL_HOSTS = {
	#"EU": "m.eu.mobileservice.blizzard.com",
	#"US": "m.us.mobileservice.blizzard.com",
	"EU": "eu.mobile-service.blizzard.com",
	"US": "us.mobile-service.blizzard.com",
	"default": "mobile-service.blizzard.com",
}

class HTTPError(Exception):
	pass

def getEmptyEncryptMsg(otp, region, model):
	ret = (otp + "\0" * 37)[:37]
	ret += region or "\0\0"
	ret += (model + "\0" * 16)[:16]
	return chr(1) + ret

def doEnroll(data, enroll_host=ENROLL_HOSTS["default"], enroll_uri="/enrollment/enroll.htm"):
	"""
	Send computed data to Blizzard servers
	Return the answer from the server
	"""
	from httplib import HTTPConnection
	
	conn = HTTPConnection(enroll_host)
	conn.request("POST", enroll_uri, data)
	response = conn.getresponse()
	
	if response.status != 200:
		raise HTTPError("%s returned status %i" % (enroll_host, response.status))
	
	ret = response.read()
	conn.close()
	return ret

def encrypt(data):
	data = int(data.encode("hex"), 16)
	n = data ** RSA_MOD % RSA_KEY
	ret = ""
	while n > 0:
{'fraction_non_alphanumeric': 0.1280579885231048, 'fraction_numerical': 0.20114768951978254, 'mean_word_length': 5.773006134969325, 'pattern_counts': {'":': 10, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1302858', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1241, 'n_words': 249}