Skip to content

Commit 14b12ac

Browse files
committed
Add /bsha/ function to web server
Any data submitted after /bsha/ in the URL will be converted to bytes, hashed with BrokenSHA1, and the data will be returned as a hex-string in the same form used for storing IPs in the statistics database.
1 parent 5229765 commit 14b12ac

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

HTTP/HTTPParse.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ public void run(){
210210
}catch(FileNotFoundException e){
211211
send404(file);
212212
}
213+
}else if(file.startsWith("/bsha/")) {
214+
String input = file.substring(6);
215+
216+
int[] hash = Hashing.BrokenSHA1.calcHashBuffer(input.getBytes());
217+
writeBytes(HTTPServer.buildHeader(200, "text/plain", 40) + CRLF +
218+
util.PadString.padHex(hash[0], 8) +
219+
util.PadString.padHex(hash[1], 8) +
220+
util.PadString.padHex(hash[2], 8) +
221+
util.PadString.padHex(hash[3], 8) +
222+
util.PadString.padHex(hash[4], 8));
213223

214224
}/*else if(file.equalsIgnoreCase("/WAR3.zip"))
215225
sendHashFile("WAR3", Constants.WAR3files);

0 commit comments

Comments
 (0)