Blockland Forums > Suggestions & Requests
MD5 and Array
BobAndRob:
--- Quote from: mctwist on March 01, 2010, 02:17:36 PM ---First off, it would be good to have MD5 encryption included in the game, due it would be more secure to first encrypt the text, and then send it over to the server. Of course this would be best with for passwords.
http://www.torquepowered.com/community/blogs/view/4392
--- End quote ---
MD5 is a hashing algorithm, not encryption (you can't un-do it). You can do basic encryption already in torquescript, in fact my final project for my cryptology class was a cipher written in torquescript.
--- Quote from: mctwist on March 01, 2010, 02:17:36 PM ---Secondly, I think that some people miss how easy an array should be, so I found this Array object that could be really useful, not just for storing data, but also managing everything better rather than store it in simple arrays or strings.
http://www.torquepowered.com/community/resources/view/4711
--- End quote ---
Torquescript should have real arrays to begin with. (Although I do like the naming system and export().)
Kalphiter:
Need ArrayList.
Similar to a SimObject except it add()s strings instead of objects.
Truce:
--- Quote from: Kalphiter on March 01, 2010, 04:16:47 PM ---Need ArrayList.
--- End quote ---
I've never used it, but:
--- Code: ---function ArrayList::onAdd(%this)
{
%this.size = 0;
%initialCapacity = %this.initialCapacity;
%c = %this.c;
%this.initialCapacity = "";
%this.c = "";
if(mFloor(%initialCapacity) $= %initialCapacity)
{
if(%initialCapacity < 0)
{
warn(%this SPC "[ArrayList]: Illegal argument exception.");
return;
}
%this.capacity = %initialCapacity;
}
else if(%c.class $= "ArrayList")
{
for(%i = 0; %i < %c.size; %i++)
{
%this._[%this.size] = %c._[%i];
%this.size++;
}
%this.capacity = %this.size * 1.1;
}
else
%this.capacity = 10;
}
function ArrayList::add(%this,%a,%b)
{
if(%b $= "")
{
if(%this.size == %this.capacity)
return;
%this._[%this.size] = %a;
%this.size++;
return true;
}
%a = mFloor(%a);
if(%a < 0 || %a > %this.size)
{
warn(%this SPC "[ArrayList]: Index out of bounds exception.");
return;
}
for(%i = %this.size; %i > %a; %i--)
%this._[%i] = %this._[%i - 1];
%this._[%a] = %b;
if(%this.size == %this.capacity)
%this._[%this.size] = "";
else
%this.size++;
return;
}
function ArrayList::addAll(%this,%a,%b)
{
if(%b $= "")
{
if(%a.class !$= "ArrayList")
{
warn(%this SPC "[ArrayList]: Null pointer exception.");
return;
}
for(%i = 0; %i < %a.size; %i++)
{
if(%this.size == %this.capacity)
break;
%this._[%this.size] = %a._[%i];
%this.size++;
}
return true;
}
%a = mFloor(%a);
if(%a < 0 || %a > %this.size)
{
warn(%this SPC "[ArrayList]: Index out of bounds exception.");
return;
}
if(%b.class !$= "ArrayList")
{
warn(%this SPC "[ArrayList]: Null pointer exception.");
return;
}
for(%i = %this.size - 1; %i >= %a; %i--)
{
if(%i + %b.size + 1 > %this.capacity)
%this.size--;
else
%this._[%i + %b.size] = %this._[%i];
}
for(%i = 0; %i < %b.size; %i++)
{
if(%i + %a + 1 >= %this.capacity)
break;
%this._[%i + %a] = %b._[%i];
%this.size++;
}
return true;
}
function ArrayList::clear(%this)
{
for(%i = 0; %i < %this.size; %i++)
%this._[%i] = "";
%this.size = 0;
return;
}
function ArrayList::clone(%this)
{
%a = new ScriptObject()
{
class = "ArrayList";
capacity = %this.capacity;
};
for(%i = 0; %i < %this.size; %i++)
%a._[%i] = %this._[%i];
%a.size = %this.size;
return %a;
}
function ArrayList::contains(%this,%a)
{
if(isObject(%a))
%c = %a.getID();
for(%i = 0; %i < %this.size; %i++)
{
if(isObject(%this._[%i]))
%b = %this._[%i].getID();
else
%b = "";
if(%this._[%i] $= %a || (%b !$= "" && %b == %c))
return true;
}
return false;
}
function ArrayList::containsAll(%this,%a)
{
if(%a.class !$= "ArrayList")
{
warn(%this SPC "[ArrayList]: Null pointer exception.");
return;
}
for(%i = 0; %i < %a.size; %i++)
{
%skip = 0;
if(isObject(%a._[%i]))
%c = %a._[%i].getID();
for(%j = 0; %j < %this.size; %j++)
{
if(isObject(%this._[%j]))
%b = %this._[%j].getID();
else
%b = "";
if(%this._[%j] $= %a._[%i] || (%b !$= "" && %b == %c))
{
%skip = 1;
break;
}
}
if(!%skip)
return false;
}
return true;
}
function ArrayList::ensureCapacity(%this,%a)
{
%a = mFloor(%a);
if(%this.capacity < %a)
%this.capacity = %a;
return;
}
function ArrayList::get(%this,%a)
{
%a = mFloor(%a);
if(%a < 0 || %a > %this.size)
{
warn(%this SPC "[ArrayList]: Index out of bounds exception.");
return;
}
return %this._[%a];
}
function ArrayList::indexOf(%this,%a)
{
if(isObject(%a))
%c = %a.getID();
for(%i = 0; %i < %this.size; %i++)
{
if(isObject(%this._[%i]))
%b = %this._[%i].getID();
else
%b = "";
if(%this._[%i] $= %a || (%b !$= "" && %b == %c))
return %i;
}
return -1;
}
function ArrayList::isEmpty(%this)
{
if(%this.size == 0)
return true;
return false;
}
function ArrayList::iterator(%this)
{
%a = new ScriptObject()
{
class = "Iterator";
size = %this.size;
index = 0;
};
return %a;
}
function ArrayList::lastIndexOf(%this,%a)
{
if(isObject(%a))
%c = %a.getID();
for(%i = %this.size - 1; %i > -1; %i++)
{
if(isObject(%this._[%i]))
%b = %this._[%i].getID();
else
%b = "";
if(%this._[%i] $= %a || (%b !$= "" && %b == %c))
return %i;
}
return -1;
}
function ArrayList::remove(%this,%a)
{
if(isObject(%a))
{
%b = %a.getID();
for(%i = 0; %i < %this.size; %i++)
{
if(isObject(%this._[%i]))
%b = %this._[%i].getID();
else
%b = "";
if(%this._[%i] $= %a || (%b !$= "" && %b == %c))
{
for(%i = %i; %i < %this.size; %i++)
%this._[%i] = %this._[%i + 1];
%this.size--;
return true;
}
}
}
%a = mFloor(%a);
if(%a < 0 || %a > %this.size)
{
warn(%this SPC "[ArrayList]: Index out of bounds exception.");
return;
}
%b = %this._[%a];
for(%i = %a; %i < %this.size; %i++)
%this._[%i] = %this._[%i + 1];
%this.size--;
return %b;
}
function ArrayList::removeAll(%this,%a)
{
if(%b.class !$= "ArrayList")
{
warn(%this SPC "[ArrayList]: Null pointer exception.");
return;
}
for(%i = 0; %i < %a.size; %i++)
{
if(isObject(%a._[%i]))
%c = %a._[%i].getID();
for(%j = 0; %j < %this.size; %j++)
{
if(isObject(%this._[%j]))
%b = %this._[%j].getID();
else
%b = "";
if(%this._[%j] $= %a._[%i] || (%b !$= "" && %b == %c))
{
for(%k = %j; %k < %this.size; %k++)
%this._[%k] = %this._[%k + 1];
%this.size--;
%change = true;
}
}
}
return %change;
}
function ArrayList::removeRange(%this,%a,%b)
{
%a = mFloor(%a);
%b = mFloor(%b);
if(%a == %b)
return;
for(%i = %a; %i < %b; %i++)
%this._[%i] = "";
for(%i = 0; %i < %this.size - %b + 1; %i++)
%this._[%a + %i] = %this._[%b + %i];
%this.size -= %b - %a;
return;
}
function ArrayList::retainAll(%this,%a)
{
if(%b.class !$= "ArrayList")
{
warn(%this SPC "[ArrayList]: Null pointer exception.");
return;
}
for(%i = 0; %i < %a.size; %i++)
{
if(isObject(%a._[%i]))
%c = %a._[%i].getID();
for(%j = 0; %j < %this.size; %j++)
{
if(isObject(%this._[%j]))
%b = %this._[%j].getID();
else
%b = "";
if(!(%this._[%j] $= %a._[%i] || (%b !$= "" && %b == %c)))
{
for(%k = %j; %k < %this.size; %k++)
%this._[%k] = %this._[%k + 1];
%this.size--;
%change = true;
}
}
}
return %change;
}
function ArrayList::set(%this,%a,%b)
{
%a = mFloor(%a);
if(%a < 0 || %a > %this.size)
{
warn(%this SPC "[ArrayList]: Index out of bounds exception.");
return;
}
%c = %this._[%a];
%this._[%a] = %b;
return %c;
}
function ArrayList::size(%this)
{
return %this.size;
}
function ArrayList::subList(%this,%a,%b)
{
%a = mFloor(%a);
%b = mFloor(%b);
if(%a < 0 || %b > %this.size)
{
warn(%this SPC "[ArrayList]: Index out of bounds exception.");
return;
}
if(%b > %a)
{
warn(%this SPC "[ArrayList]: Illegal argument exception.");
return;
}
%c = new ScriptObject()
{
class = "ArrayList";
capacity = %b - %a;
};
for(%i = %a; %i < %b; %i++)
{
%c._[%c.size] = %this._[%i];
%c.size++;
}
return %c;
}
function ArrayList::toString(%this)
{
%str = "[";
for(%i = 0; %i < %this.size; %i++)
%str = %str @ %this._[%i] @ ", ";
return getSubStr(%str,0,strLen(%str) - 2) @ "]";
}
function ArrayList::trimToSize(%this)
{
%this.capacity = %this.size;
return;
}
function Iterator::hasNext(%this)
{
if(%this.index < %this.size)
return true;
return false;
}
function Iterator::next(%this)
{
if(%this.index == %this.size)
{
warn(%this SPC "[Iterator]: No such element exception.");
return;
}
%a = %this._[%this.index];
%this.index++;
%this.calledNext = true;
return %a;
}
function Iterator::remove(%this)
{
if(!%this.calledNext)
{
warn(%this SPC "[Iterator]: Illegal state exception.");
return;
}
for(%i = %this.index; %i < %this.size; %i++)
%this._[%i] = %this._[%i + 1];
%this.calledNext = false;
%this.size--;
%this.underlying.remove(%this.index);
return;
}
--- End code ---
mctwist:
--- Quote from: Kalphiter on March 01, 2010, 04:12:22 PM ---Last time I checked, you can't steal a key out of nowhere.
--- End quote ---
Ephi needs to verify what needs to be sent to the RTB Connect server to actually connect to it. I doubt he'll send the encrypted key.
--- Quote from: BobAndRob on March 01, 2010, 04:15:23 PM ---MD5 is a hashing algorithm, not encryption (you can't un-do it). You can do basic encryption already in torquescript, in fact my final project for my cryptology class was a cipher written in torquescript.
Torquescript should have real arrays to begin with. (Although I do like the naming system and export().)
--- End quote ---
First, I wrote wrong, and that's my mistake.
Secondly, Arrays are nice, because how they work.
--- Quote from: Kalphiter on March 01, 2010, 04:16:47 PM ---Need ArrayList.
Similar to a SimObject except it add()s strings instead of objects.
--- End quote ---
Didn't I suggested it?
Die you posting too fast people!
Kalphiter:
--- Quote from: mctwist on March 01, 2010, 04:19:25 PM ---Ephi needs to verify what needs to be sent to the RTB Connect server to actually connect to it. I doubt he'll send the encrypted key.
--- End quote ---
That's the point, RTB checks the master server to see if the IP matches the ID