28 |
28 |
import java.net.HttpURLConnection;
|
29 |
29 |
import java.net.URL;
|
30 |
30 |
import java.net.UnknownHostException;
|
|
31 |
import java.security.MessageDigest;
|
|
32 |
import java.security.NoSuchAlgorithmException;
|
31 |
33 |
|
32 |
34 |
import static org.distorted.objects.RubikObjectList.MAX_LEVEL;
|
33 |
35 |
|
... | ... | |
98 |
100 |
private static RubikScoresDownloader mThis;
|
99 |
101 |
|
100 |
102 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101 |
|
// TODO
|
102 |
103 |
|
103 |
|
private static int computeHash(String name, String veri, String country, String lvllist,
|
104 |
|
String objlist, String timelist, int runnings)
|
|
104 |
private static String computeHash(String stringToHash, byte[] salt)
|
105 |
105 |
{
|
106 |
|
int length, hash = 0;
|
107 |
|
|
108 |
|
length = name.length();
|
109 |
|
for(int i=0; i<length; i++) hash += i*name.charAt(i);
|
110 |
|
length = veri.length();
|
111 |
|
for(int i=0; i<length; i++) hash += i*veri.charAt(i);
|
112 |
|
length = country.length();
|
113 |
|
for(int i=0; i<length; i++) hash += i*country.charAt(i);
|
114 |
|
length = lvllist.length();
|
115 |
|
for(int i=0; i<length; i++) hash += i*lvllist.charAt(i);
|
116 |
|
length = objlist.length();
|
117 |
|
for(int i=0; i<length; i++) hash += i*objlist.charAt(i);
|
118 |
|
length = timelist.length();
|
119 |
|
for(int i=0; i<length; i++) hash += i*timelist.charAt(i);
|
120 |
|
|
121 |
|
hash *= runnings;
|
122 |
|
hash %= 541;
|
123 |
|
|
124 |
|
return hash<0 ? -hash: hash;
|
|
106 |
String generatedPassword;
|
|
107 |
|
|
108 |
try
|
|
109 |
{
|
|
110 |
MessageDigest md = MessageDigest.getInstance("MD5");
|
|
111 |
md.update(salt);
|
|
112 |
byte[] bytes = md.digest(stringToHash.getBytes());
|
|
113 |
StringBuilder sb = new StringBuilder();
|
|
114 |
|
|
115 |
for (byte aByte : bytes)
|
|
116 |
{
|
|
117 |
sb.append(Integer.toString((aByte & 0xff) + 0x100, 16).substring(1));
|
|
118 |
}
|
|
119 |
|
|
120 |
generatedPassword = sb.toString();
|
|
121 |
}
|
|
122 |
catch (NoSuchAlgorithmException e)
|
|
123 |
{
|
|
124 |
return "NoSuchAlgorithm";
|
|
125 |
}
|
|
126 |
|
|
127 |
return generatedPassword;
|
125 |
128 |
}
|
126 |
129 |
|
127 |
130 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
330 |
333 |
String lvllist = scores.getUnsubmittedLevellist();
|
331 |
334 |
String timlist = scores.getUnsubmittedTimelist();
|
332 |
335 |
String country = scores.getCountry();
|
333 |
|
int hash = computeHash(name,veri,country,lvllist,objlist,timlist,numRuns);
|
|
336 |
long epoch = System.currentTimeMillis();
|
|
337 |
String salt = "cuboid";
|
334 |
338 |
|
335 |
|
String url="https://distorted.org/magic/cgi-bin/submit.cgi";
|
336 |
|
url += "?n="+name+"&v="+veri+"&r="+numRuns+"&p="+numPlay+"&i="+deviceID+"&e="+mVersion+"d";
|
337 |
|
url += "&o="+objlist+"&l="+lvllist+"&t="+timlist+"&c="+country+"&h="+hash;
|
338 |
|
url += "&oo="+RubikObjectList.getObjectList()+"&min=0&max="+MAX_LEVEL+"&lo="+MAX_PLACES;
|
|
339 |
String url1="https://distorted.org/magic/cgi-bin/submit.cgi";
|
|
340 |
String url2 = "n="+name+"&v="+veri+"&r="+numRuns+"&p="+numPlay+"&i="+deviceID+"&e="+mVersion+"d";
|
|
341 |
url2 += "&o="+objlist+"&l="+lvllist+"&t="+timlist+"&c="+country+"&f="+epoch;
|
|
342 |
url2 += "&oo="+RubikObjectList.getObjectList()+"&min=0&max="+MAX_LEVEL+"&lo="+MAX_PLACES;
|
|
343 |
url2 += "&h="+computeHash( url2, salt.getBytes() );
|
339 |
344 |
|
340 |
|
return url;
|
|
345 |
return url1 + "?" + url2;
|
341 |
346 |
}
|
342 |
347 |
|
343 |
348 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Minor tweaks to the 'Prev' buton in Solving state;
Relax requirements in the Manifest - now only 'android.hardware.faketouch' supporting device is required, i.e. something that supports basic point-click-drag-unclick. No need for full 'android.hardware.touchscreen' thing with its multitouch silliness.