protected void validateHandshake(String key1, String key2, byte[] clientQuad,
			byte[] serverHandshake) throws IOException, NoSuchAlgorithmException {
		StringBuilder key1Numbers=new StringBuilder(key1.length());
		StringBuilder key2Numbers=new StringBuilder(key2.length());
		int key1Spaces=0, key2Spaces=0;
		
		// Scan key1 for numbers and spaces
		for (int i=0; i<key1.length(); i++) {
			char c=key1.charAt(i);
			if (c==' ') key1Spaces++;
			else if (c>='0' && c<='9') key1Numbers.append(c);
		}
		
		// Scan key2 for numbers and spaces
		for (int i=0; i<key2.length(); i++) {
			char c=key2.charAt(i);
			if (c==' ') key2Spaces++;
			else if (c>='0' && c<='9') key2Numbers.append(c);
		}
		
		int key1Int=Integer.parseInt(key1Numbers.toString()) / key1Spaces;
		int key2Int=Integer.parseInt(key2Numbers.toString()) / key2Spaces;
		
		ByteArrayOutputStream bufferOut=new ByteArrayOutputStream(16);
		DataOutputStream bufferData=new DataOutputStream(bufferOut);
		bufferData.writeInt(key1Int);
		bufferData.writeInt(key2Int);
		bufferData.write(clientQuad);
		
		byte[] buffer=bufferOut.toByteArray();
		MessageDigest digest=MessageDigest.getInstance("MD5");
		byte[] clientHandshake=digest.digest(buffer);
		
		if (!Arrays.equals(clientHandshake, serverHandshake)) {
			throw new IOException("Client and server handshake don't match:\nraw=" + Arrays.toString(buffer) + "\nclient=" + Arrays.toString(clientHandshake) + "\nserver=" + Arrays.toString(serverHandshake));
		} else {
			//System.out.println("Handshakes match");
		}
	}