Skip to content

Commit

Permalink
Add /bsha/ function to web server
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Davnit committed Mar 21, 2018
1 parent 5229765 commit 14b12ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions HTTP/HTTPParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ public void run(){
}catch(FileNotFoundException e){
send404(file);
}
}else if(file.startsWith("/bsha/")) {
String input = file.substring(6);

int[] hash = Hashing.BrokenSHA1.calcHashBuffer(input.getBytes());
writeBytes(HTTPServer.buildHeader(200, "text/plain", 40) + CRLF +
util.PadString.padHex(hash[0], 8) +
util.PadString.padHex(hash[1], 8) +
util.PadString.padHex(hash[2], 8) +
util.PadString.padHex(hash[3], 8) +
util.PadString.padHex(hash[4], 8));

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

0 comments on commit 14b12ac

Please sign in to comment.