Blockland Forums > General Discussion
HamHost Dedicated Blockland servers | New poll: More free-user features?
<< < (28/216) > >>
Tyler66:

--- Quote from: hammereditor² on August 12, 2013, 06:06:34 PM ---This is exactly the purpose of the SHA-256. It ensures that people cannot just match the file size and the file name, but the file must also contain the same content.

--- End quote ---
Then why aren't you using it on the file contents? From what I read, you're only matching name and file length for integrity. It would make more sense if you used a hash on the files as well.
jleneau:

--- Quote from: hammereditor² on August 12, 2013, 12:50:46 PM ---Chat is printed out to the Blockland console, so they can see the chat through the remote console feature.

--- End quote ---
Ah, I see, kk.
hammereditor²:

--- Quote from: Tyler66 on August 12, 2013, 06:13:18 PM ---Then why aren't you using it on the file contents? From what I read, you're only matching name and file length for integrity. It would make more sense if you used a hash on the files as well.

--- End quote ---
Yes, I do use the hash on the file contents. That's the whole point of the hash anyway.
Java code:

--- Code: ---public static final String generateHash(File file)
{
String hash = "";
try
{
FileInputStream fileReader = new FileInputStream(file);
byte[] data = new byte[(int)file.length()]; //will only work up to 2 GB; Blockland.exe is only 3.7 MB
fileReader.read(data); //[b]This reads the file's contents.[/b]
fileReader.close();
//getting the value from the array
MessageDigest md = MessageDigest.getInstance("SHA-256");
md5.update(data);
byte[] digest = md.digest(); //will take a lot of time

for (int i = 0; i < digest.length; i++)
{
hash += digest[i];
}

}
catch (Exception e)
{
hash = "";
e.printStackTrace();
}
return hash;
}

--- End code ---
As you can see, it reads the actual contents.
Reindeer:
I just sent an e-mail to you Hammereditor, I hope I can have a server slot, thank you, also thank you for running this service.
hammereditor²:

--- Quote from: Reindeer on August 13, 2013, 08:13:35 AM ---I just sent an e-mail to you Hammereditor, I hope I can have a server slot, thank you, also thank you for running this service.

--- End quote ---
Your setup is now completed
Navigation
Message Index
Next page
Previous page

Go to full version