<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://gtamods.com/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=AkifIe47</id>
	<title>GTAMods Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://gtamods.com/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=AkifIe47"/>
	<link rel="alternate" type="text/html" href="https://gtamods.com/wiki/Special:Contributions/AkifIe47"/>
	<updated>2026-04-15T06:02:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://gtamods.com/mediawiki/index.php?title=TOBJ&amp;diff=19576</id>
		<title>TOBJ</title>
		<link rel="alternate" type="text/html" href="https://gtamods.com/mediawiki/index.php?title=TOBJ&amp;diff=19576"/>
		<updated>2024-09-29T19:35:20Z</updated>

		<summary type="html">&lt;p&gt;AkifIe47: corrected NightFlags to ActiveHours and added statistics for GTAIV.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{IdeSection&lt;br /&gt;
|game        = {{Icon|t}} {{Icon|LCS}} {{Icon|4}}&lt;br /&gt;
|description = Defines timed map objects&lt;br /&gt;
}}&lt;br /&gt;
'''&amp;lt;code&amp;gt;tobj&amp;lt;/code&amp;gt;''' is a section in the [[item definition]] file in [[GTA III]], [[Vice City]], [[San Andreas]], [[Liberty City Stories]], and [[GTA IV]]. It is used to define standard map objects similar to the &amp;lt;code&amp;gt;[[OBJS|objs]]&amp;lt;/code&amp;gt; section with an additional in-game time range defining when the object gets rendered. [[GTA IV]] also support time controlled objects linked to animations through the &amp;lt;code&amp;gt;[[TANM|tanm]]&amp;lt;/code&amp;gt; section. Most, if not all, time objects use the [[Item Definition#IDE Flags|object flag]] 2 to prevent them from fading into and out of view at those times.&lt;br /&gt;
&lt;br /&gt;
== Format ==&lt;br /&gt;
=== GTA III &amp;amp;ndash; Liberty City Stories ===&lt;br /&gt;
{{Pre|&lt;br /&gt;
tobj&lt;br /&gt;
# [[#Type 1|type 1]] (III/VC/SA/LCS)&lt;br /&gt;
Id, ModelName, TxdName, MeshCount, DrawDistance, Flags, TimeOn, TimeOff&lt;br /&gt;
# [[#Type 2|type 2]] (III/VC/SA/LCS)&lt;br /&gt;
Id, ModelName, TxdName, MeshCount, DrawDistance1, DrawDistance2, Flags, TimeOn, TimeOff&lt;br /&gt;
# [[#Type 3|type 3]] (III/VC/SA/LCS)&lt;br /&gt;
Id, ModelName, TxdName, MeshCount, DrawDistance1, DrawDistance2, DrawDistance3, Flags, TimeOn, TimeOff&lt;br /&gt;
# [[#Type 4|type 4]] (SA)&lt;br /&gt;
Id, ModelName, TxdName, DrawDistance, Flags, TimeOn, TimeOff&lt;br /&gt;
end&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
====Type 1====&lt;br /&gt;
This is used for non-breakable objects.&lt;br /&gt;
{|class=&amp;quot;wikitable center-col-1 center-col-2&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
!style=&amp;quot;width: 3em;&amp;quot; |{{Icon|3}} {{Icon|VC}}&amp;lt;br&amp;gt;{{Icon|SA}} {{Icon|LCS}}&lt;br /&gt;
!style=&amp;quot;width: 12em;&amp;quot; |Identifier&lt;br /&gt;
!style=&amp;quot;width: 6em;&amp;quot; |Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|A ||Id ||integer ||Unique object identifier.&lt;br /&gt;
|-&lt;br /&gt;
|B ||ModelName ||string ||Name of the [[model file]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|C ||TxdName ||string ||Name of the [[texture dictionary]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|D ||MeshCount ||integer ||Number of meshes. 1 for this type.&lt;br /&gt;
|-&lt;br /&gt;
|E ||DrawDistance ||float ||[[Draw distance]] in [[unit]]s.&lt;br /&gt;
|-&lt;br /&gt;
|F ||Flags ||integer ||[[Item Definition#IDE Flags|Object flags]]&lt;br /&gt;
|-&lt;br /&gt;
|G ||TimeOn ||integer ||Hour to appear&lt;br /&gt;
|-&lt;br /&gt;
|H ||TimeOff ||integer ||Hour to disappear&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Type 2====&lt;br /&gt;
This is used for breakable objects.&lt;br /&gt;
{|class=&amp;quot;wikitable center-col-1 center-col-2&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
!style=&amp;quot;width: 3em;&amp;quot; |{{Icon|3}} {{Icon|VC}}&amp;lt;br&amp;gt;{{Icon|SA}} {{Icon|LCS}}&lt;br /&gt;
!style=&amp;quot;width: 12em;&amp;quot; |Identifier&lt;br /&gt;
!style=&amp;quot;width: 6em;&amp;quot; |Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|A ||Id ||integer ||Unique object identifier.&lt;br /&gt;
|-&lt;br /&gt;
|B ||ModelName ||string ||Name of the [[model file]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|C ||TxdName ||string ||Name of the [[texture dictionary]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|D ||MeshCount ||integer ||Number of meshes. 2 for this type.&lt;br /&gt;
|-&lt;br /&gt;
|E,F ||DrawDistance1, DrawDistance2 ||float[2] ||[[Draw distance]] in [[unit]]s (one for each mesh, only the first is actually used).&lt;br /&gt;
|-&lt;br /&gt;
|G ||Flags ||integer ||[[Item Definition#IDE Flags|Object flags]]&lt;br /&gt;
|-&lt;br /&gt;
|H ||TimeOn ||integer ||Hour to appear&lt;br /&gt;
|-&lt;br /&gt;
|I ||TimeOff ||integer ||Hour to disappear&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Type 3====&lt;br /&gt;
This is used for complex breakable objects.&lt;br /&gt;
{|class=&amp;quot;wikitable center-col-1 center-col-2&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
!style=&amp;quot;width: 3em;&amp;quot; |{{Icon|3}} {{Icon|VC}}&amp;lt;br&amp;gt;{{Icon|SA}} {{Icon|LCS}}&lt;br /&gt;
!style=&amp;quot;width: 12em;&amp;quot; |Identifier&lt;br /&gt;
!style=&amp;quot;width: 6em;&amp;quot; |Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|A ||Id ||integer ||Unique object identifier.&lt;br /&gt;
|-&lt;br /&gt;
|B ||ModelName ||string ||Name of the [[model file]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|C ||TxdName ||string ||Name of the [[texture dictionary]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|D ||MeshCount ||integer ||Number of meshes. 3 for this type.&lt;br /&gt;
|-&lt;br /&gt;
|E,F,G ||DrawDistance1, DrawDistance2, DrawDistance3 ||float[3] ||[[Draw distance]] in [[unit]]s (one for each mesh, only the first is actually used).&lt;br /&gt;
|-&lt;br /&gt;
|H ||Flags ||integer ||[[Item Definition#IDE Flags|Object flags]]&lt;br /&gt;
|-&lt;br /&gt;
|I ||TimeOn ||integer ||Hour to appear&lt;br /&gt;
|-&lt;br /&gt;
|J ||TimeOff ||integer ||Hour to disappear&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Type 4====&lt;br /&gt;
This is used for non-breakable objects and behaves equivalently to [[#Type 1|Type 1]].&lt;br /&gt;
{|class=&amp;quot;wikitable center-col-1 center-col-2&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
!style=&amp;quot;width: 3em;&amp;quot; |{{Icon|SA}}&lt;br /&gt;
!style=&amp;quot;width: 12em;&amp;quot; |Identifier&lt;br /&gt;
!style=&amp;quot;width: 6em;&amp;quot; |Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|A ||Id ||integer ||Unique object identifier.&lt;br /&gt;
|-&lt;br /&gt;
|B ||ModelName ||string ||Name of the [[model file]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|C ||TxdName ||string ||Name of the [[texture dictionary]] without extension.&lt;br /&gt;
|-&lt;br /&gt;
|D ||DrawDistance ||float ||[[Draw distance]] in [[unit]]s.&lt;br /&gt;
|-&lt;br /&gt;
|E ||Flags ||integer ||[[Item Definition#IDE Flags|Object flags]]&lt;br /&gt;
|-&lt;br /&gt;
|F ||TimeOn ||integer ||Hour to appear&lt;br /&gt;
|-&lt;br /&gt;
|G ||TimeOff ||integer ||Hour to disappear&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== GTA IV ===&lt;br /&gt;
{{Pre|&lt;br /&gt;
tobj&lt;br /&gt;
ModelName, TxdName, DrawDistance, Flags, Unknown, MinX, MinY, MinZ, MaxX, MaxY, MaxZ, SphereX, SphereY, SphereZ, Radius, LODModel, NightFlag&lt;br /&gt;
end&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable center-col-1 center-col-2&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
!style=&amp;quot;width: 3em;&amp;quot; |{{Icon|4}}&lt;br /&gt;
!style=&amp;quot;width: 12em;&amp;quot; |Identifier&lt;br /&gt;
!style=&amp;quot;width: 6em;&amp;quot; |Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|A ||ModelName ||string ||Name of the &amp;lt;code&amp;gt;.wdr&amp;lt;/code&amp;gt; ''model file'' without extension.&lt;br /&gt;
|-&lt;br /&gt;
|B ||TxdName ||string ||name of the &amp;lt;code&amp;gt;.wtd&amp;lt;/code&amp;gt; ''texture dictionary'' without extension.&lt;br /&gt;
|-&lt;br /&gt;
|C ||DrawDistance ||float ||Draw distance in units.&lt;br /&gt;
|-&lt;br /&gt;
|D ||Flags ||integer ||[[Item Definition#IDE Flags|Object flag]]&lt;br /&gt;
|-&lt;br /&gt;
|E ||''unknown'' ||float ||Unknown integer (0 by default).&lt;br /&gt;
|-&lt;br /&gt;
|F,G,H ||MinX, MinY, MinZ ||float[3] ||Lower left corner of the bounding box for the object.&lt;br /&gt;
|-&lt;br /&gt;
|I,J,K ||MaxX, MaxY, MaxZ ||float[3] ||Upper right corner of the bounding box for the object.&lt;br /&gt;
|-&lt;br /&gt;
|L,M,N ||SphereX, SphereY, SphereZ ||float[3] ||Center of the bounding sphere for the object.&lt;br /&gt;
|-&lt;br /&gt;
|O ||Radius ||float ||Radius of the bounding sphere into all dimensions.&lt;br /&gt;
|-&lt;br /&gt;
|P ||LODModel||string ||Name of the &amp;lt;code&amp;gt;[[WDD|.wdd]]&amp;lt;/code&amp;gt; file that contains the ''lod model'' for the defined modelname.&lt;br /&gt;
|-&lt;br /&gt;
|Q ||ActiveHours||integer ||Hours of the day where the model is active as a bit field. with the first bit being midnight and the 24th 11PM.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Statistics ==&lt;br /&gt;
Total number of &amp;lt;code&amp;gt;tobj&amp;lt;/code&amp;gt; entries in:&lt;br /&gt;
:GTA III: 24 (max 30)&lt;br /&gt;
:Vice City: 342 (max 385)&lt;br /&gt;
:San Andreas: 160&lt;br /&gt;
:GTA IV: 1558&lt;br /&gt;
&lt;br /&gt;
{{N|4|LCS|SA|VC|3}}&lt;br /&gt;
[[Category:GTA LCS]]&lt;/div&gt;</summary>
		<author><name>AkifIe47</name></author>
		
	</entry>
	<entry>
		<id>https://gtamods.com/mediawiki/index.php?title=Cryptography&amp;diff=19575</id>
		<title>Cryptography</title>
		<link rel="alternate" type="text/html" href="https://gtamods.com/mediawiki/index.php?title=Cryptography&amp;diff=19575"/>
		<updated>2024-09-23T17:50:41Z</updated>

		<summary type="html">&lt;p&gt;AkifIe47: Added 1.0.8.0's key offset.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains the [[Wikipedia:Cryptography|cryptography]] present in GTA SA &amp;amp; IV.&lt;br /&gt;
&lt;br /&gt;
==GTA San Andreas==&lt;br /&gt;
===Hashing Algorithms===&lt;br /&gt;
====CRC32====&lt;br /&gt;
San Andreas only uses the JAMCRC variation of the original CRC32 hashing algorithm. In JAMCRC bits of the final result are not inverted, whereas in the original CRC32 algorithm they are. It is mainly used for fast string comparison throughout the whole executable and also for GXT keys to speed up the binary search at runtime.&lt;br /&gt;
&lt;br /&gt;
To calculate the JAMCRC hash for a string, it is possible to simply avoid to invert the output bits in a normal CRC32 algorithm (unfinalized hash).&amp;lt;sup&amp;gt;[https://github.com/llvm/llvm-project/blob/1e1e3ba2526ecab1ad3c18c97abef36df00b3813/llvm/include/llvm/Support/CRC.h#L40|1]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The original C++ implementation of GTA San Andreas' CRC32 hashing algorithm class can be displayed as follows:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;class CKeyGen&lt;br /&gt;
{&lt;br /&gt;
private:&lt;br /&gt;
    // Precalculated table of 256 CRC32 hash keys computed according to the polynomial 0xEDB88320.&lt;br /&gt;
    static const unsigned int keyTable[] = // 0x008CD068&lt;br /&gt;
    {&lt;br /&gt;
        0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,&lt;br /&gt;
        0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,&lt;br /&gt;
        0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,&lt;br /&gt;
        0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,&lt;br /&gt;
        0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,&lt;br /&gt;
        0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,&lt;br /&gt;
        0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,&lt;br /&gt;
        0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,&lt;br /&gt;
        0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,&lt;br /&gt;
        0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,&lt;br /&gt;
        0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,&lt;br /&gt;
        0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,&lt;br /&gt;
        0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,&lt;br /&gt;
        0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,&lt;br /&gt;
        0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,&lt;br /&gt;
        0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,&lt;br /&gt;
        0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,&lt;br /&gt;
        0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,&lt;br /&gt;
        0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,&lt;br /&gt;
        0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,&lt;br /&gt;
        0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,&lt;br /&gt;
        0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,&lt;br /&gt;
        0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,&lt;br /&gt;
        0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,&lt;br /&gt;
        0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,&lt;br /&gt;
        0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,&lt;br /&gt;
        0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,&lt;br /&gt;
        0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,&lt;br /&gt;
        0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,&lt;br /&gt;
        0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,&lt;br /&gt;
        0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,&lt;br /&gt;
        0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
public:&lt;br /&gt;
    // Hash a string till the specified number of characters.&lt;br /&gt;
    static unsigned int GetKey(const char *str, int len) // 0x0053CED0&lt;br /&gt;
    {&lt;br /&gt;
        unsigned int hash = 0xFFFFFFFF;&lt;br /&gt;
        for(int i = 0; i &amp;lt; len; i++)&lt;br /&gt;
            hash = keyTable[(unsigned char)hash ^ *str++] ^ (hash &amp;gt;&amp;gt; 8);&lt;br /&gt;
        return hash;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Hash a string till a null-terminator is found.&lt;br /&gt;
    static unsigned int GetKey(const char *str) // 0x0053CF00&lt;br /&gt;
    {&lt;br /&gt;
        unsigned int hash = 0xFFFFFFFF;&lt;br /&gt;
        while(*str)&lt;br /&gt;
            hash = keyTable[(unsigned char)hash ^ *str++] ^ (hash &amp;gt;&amp;gt; 8);&lt;br /&gt;
        return hash;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Hash a string till a null-terminator is found by converting lowercase characters to uppercase.&lt;br /&gt;
    static unsigned int GetUppercaseKey(const char *str) // 0x0053CF30&lt;br /&gt;
    {&lt;br /&gt;
        unsigned int hash = 0xFFFFFFFF;&lt;br /&gt;
        while(*str)&lt;br /&gt;
            hash = keyTable[(unsigned char)hash ^ toupper(*str++)] ^ (hash &amp;gt;&amp;gt; 8);&lt;br /&gt;
        return hash;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Append a string to the hash key of a previously hashed string.&lt;br /&gt;
    static unsigned int AppendStringToKey(unsigned int hash, const char *str) // 0x0053CF70&lt;br /&gt;
    {&lt;br /&gt;
        while(*str)&lt;br /&gt;
            hash = keyTable[(unsigned char)hash ^ *str++] ^ (hash &amp;gt;&amp;gt; 8);&lt;br /&gt;
        return hash;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GTA IV==&lt;br /&gt;
===Hashing Algorithms===&lt;br /&gt;
&lt;br /&gt;
GTA IV relies on many different hash algorithms work its operation, each for a different purpose. GTA IV's new usage of hashing has allowed it to explore a more binary focused way of hiding data in files, and strings away from plain sight.&lt;br /&gt;
&lt;br /&gt;
====SHA1====&lt;br /&gt;
&lt;br /&gt;
The [[Wikipedia:SHA1|SHA1]] hashing algorithm is used when comparing the files in versions 1.0 and 1.0.1. This check was later removed in 1.0.2.&lt;br /&gt;
&lt;br /&gt;
{{Incomplete}}&lt;br /&gt;
&lt;br /&gt;
====CRC32====&lt;br /&gt;
&lt;br /&gt;
The ''Cyclic Redundancy Check 32'' bit hashing algorithm is used in the GXT file to match text codes with their counterparts. A C++ implementation of GTA IV's CRC32 hashing algorithm can be displayed as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;unsigned int CRC32(char* text)&lt;br /&gt;
{&lt;br /&gt;
    size_t textLen = strlen(text);&lt;br /&gt;
    int i = 0;&lt;br /&gt;
    unsigned int retHash = 0;&lt;br /&gt;
    if(text[0] == '&amp;quot;')&lt;br /&gt;
        i = 1;&lt;br /&gt;
    for(i;i&amp;lt;textLen;i++)&lt;br /&gt;
    {&lt;br /&gt;
        char ctext = text[i];&lt;br /&gt;
        if(ctext == '&amp;quot;')&lt;br /&gt;
            break;&lt;br /&gt;
        if(ctext - 65 &amp;gt; 25)&lt;br /&gt;
        {&lt;br /&gt;
            if(ctext == '\\')&lt;br /&gt;
                ctext = '/';&lt;br /&gt;
        }&lt;br /&gt;
        else ctext += 32;&lt;br /&gt;
        retHash = (1025 * (retHash + ctext) &amp;gt;&amp;gt; 6) ^ 1025 * (retHash + ctext);&lt;br /&gt;
    }&lt;br /&gt;
    return 32769 * (9 * retHash ^ (9 * retHash &amp;gt;&amp;gt; 11));&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see it differs from most common hashing algorithms in the way it handles text (by not including &amp;quot; or \ characters). Also usually entry name strings in [[GXT]] text archives are stored in upper case, so it may be useful to convert them before creating the hash.&lt;br /&gt;
&lt;br /&gt;
====One At A Time Hash====&lt;br /&gt;
&lt;br /&gt;
The One At A Time hashing function was originally created by Bob Jenkins. A C++ implementation can be found here and at [[Wikipedia:Jenkins_hash_function#one-at-a-time|Wikipedia]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;unsigned int oneAtATimeHash(char* inpStr)&lt;br /&gt;
{&lt;br /&gt;
    unsigned int value = 0,temp = 0;&lt;br /&gt;
    for(size_t i=0;i&amp;lt;strlen(inpStr);i++)&lt;br /&gt;
    {&lt;br /&gt;
        char ctext = tolower(inpStr[i]);&lt;br /&gt;
        temp = hashchr;&lt;br /&gt;
        temp += value;&lt;br /&gt;
        value = temp &amp;lt;&amp;lt; 10;&lt;br /&gt;
        temp += value;&lt;br /&gt;
        value = temp &amp;gt;&amp;gt; 6;&lt;br /&gt;
        value ^= temp;&lt;br /&gt;
    }&lt;br /&gt;
    temp = value &amp;lt;&amp;lt; 3;&lt;br /&gt;
    temp += value;&lt;br /&gt;
    unsigned int temp2 = temp &amp;gt;&amp;gt; 11;&lt;br /&gt;
    temp = temp2 ^ temp;&lt;br /&gt;
    temp2 = temp &amp;lt;&amp;lt; 15;&lt;br /&gt;
    value = temp2 + temp;&lt;br /&gt;
    if(value &amp;lt; 2) value += 2;&lt;br /&gt;
    return value;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A JavaScript implementation can be run without special tools in a web browser's console.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;js&amp;quot;&amp;gt;function oneAtATimeHash(key) {&lt;br /&gt;
    var hash = 0;&lt;br /&gt;
    for (var i = 0; i &amp;lt; key.length; ++i) {&lt;br /&gt;
        hash += key.charCodeAt(i);&lt;br /&gt;
        hash += (hash &amp;lt;&amp;lt; 10);&lt;br /&gt;
        hash ^= (hash &amp;gt;&amp;gt;&amp;gt; 6);&lt;br /&gt;
    }&lt;br /&gt;
    hash += (hash &amp;lt;&amp;lt; 3);&lt;br /&gt;
    hash ^= (hash &amp;gt;&amp;gt;&amp;gt; 11);&lt;br /&gt;
    hash += (hash &amp;lt;&amp;lt; 15);&lt;br /&gt;
    return (hash &amp;gt;&amp;gt;&amp;gt; 0).toString(16);&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Encryption Algorithms===&lt;br /&gt;
&lt;br /&gt;
====AES====&lt;br /&gt;
&lt;br /&gt;
The encryption algorithm used for [[RPF]], [[IMG]] and [[SCO]] files is the [[Wikipedia:Advanced Encryption Standard|Advanced Encryption Standard]] (AES) in the following configuration:&lt;br /&gt;
* block size: 128 bit (16 byte)&lt;br /&gt;
* key size: 256 bit (32 byte)&lt;br /&gt;
* cypher mode: [[Wikipedia:Block cipher modes of operation#Electronic_codebook_(ECB)|electronic code book]] (ECB)&lt;br /&gt;
* repetitions: 16 times&lt;br /&gt;
&lt;br /&gt;
That means all encrypted data (the cyphertext) can be split up into 16 byte blocks and decrypted independently. Decryption is done by executing the AES-128 decrypt routine 16x on each data block. If the last block is smaller than 16 byte, it is left unencrypted in Rockstar's archives.&lt;br /&gt;
&lt;br /&gt;
=====Key=====&lt;br /&gt;
&lt;br /&gt;
The 256 bit key necessary to decrypt the cyphertext can be retrieved from &amp;lt;code&amp;gt;gtaiv.exe&amp;lt;/code&amp;gt; at the following file offsets:&lt;br /&gt;
&lt;br /&gt;
{| {{Prettytable}}&lt;br /&gt;
!Game Version&lt;br /&gt;
!Offset&lt;br /&gt;
|-&lt;br /&gt;
|1.0 US || 0xA94204&lt;br /&gt;
|-&lt;br /&gt;
|1.0.1 US || 0xB607C4&lt;br /&gt;
|-&lt;br /&gt;
|1.0.2 US || 0xB56BC4&lt;br /&gt;
|-&lt;br /&gt;
|1.0.3 US || 0xB75C9C&lt;br /&gt;
|-&lt;br /&gt;
|1.0.4 US || 0xB7AEF4&lt;br /&gt;
|-&lt;br /&gt;
|1.0.6 US || 0xBE6540&lt;br /&gt;
|-&lt;br /&gt;
|1.0.7 US || 0xBE7540&lt;br /&gt;
|-&lt;br /&gt;
|1.0.8 US || 0xC95FD8&lt;br /&gt;
|-&lt;br /&gt;
|1.2.0.59 || 0xC5B73C&lt;br /&gt;
|-&lt;br /&gt;
|1.0.0.1 RUS || 0xB5B65C&lt;br /&gt;
|-&lt;br /&gt;
|1.0.1.1 RUS || 0xB569F4&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And from &amp;lt;code&amp;gt;eflc.exe&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{| {{Prettytable}}&lt;br /&gt;
!Game Version&lt;br /&gt;
!Offset&lt;br /&gt;
|-&lt;br /&gt;
|1.1.1 US || 0xC705E0&lt;br /&gt;
|-&lt;br /&gt;
|1.1.2 US || 0xBEF028&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The key is the same for all game versions on all platforms (PC, XBOX 360, PS3). You may want to use the following '''SHA1 hash''' to verify the correctness of the retrieved key:&lt;br /&gt;
 DE A3 75 EF 1E 6E F2 22 3A 12 21 C2 C5 75 C4 7B F1 7E FA 5E&lt;br /&gt;
'''''NOTE:''''' '''This is not the cypher key!''' {{Note|1}}&lt;br /&gt;
&lt;br /&gt;
It is recommended to leave modified archives unencrypted.&lt;br /&gt;
&lt;br /&gt;
===== Example =====&lt;br /&gt;
&lt;br /&gt;
Program code to decrypt data from GTA IV could look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;AES_set_decrypt_key(key, 256, context);&lt;br /&gt;
&lt;br /&gt;
for (int i = 0; i &amp;lt; (int) (data_size/16); i++) {&lt;br /&gt;
    void *p = (void *) (data_offset + i*16); // the pointer to the current block&lt;br /&gt;
    for (int j = 1; j &amp;lt;= 16; j++)            // 16 (pointless) repetitions&lt;br /&gt;
        AES_decrypt_block(p, p, context);&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''See also:'' [http://code.google.com/p/gtaivtools/source/browse/trunk/RageLib/Common/DataUtil.cs Decryption routine] in [[SparkIV]] (C#, [[Wikipedia:GNU_Public_License|GPL]])&lt;br /&gt;
&lt;br /&gt;
===== Legal Issues=====&lt;br /&gt;
&lt;br /&gt;
{{ref|1}} Since the United States complying with [[Wikipedia:WIPO|WIPO]] treaties, they created the [[Wikipedia:Digital_Millennium_Copyright_Act|Digital Millenium Copyright Act]] in order to bring their copyright laws up to date in the emerging digital world. A key point in this act is the [[Wikipedia:Digital_Millennium_Copyright_Act#Anti-circumvention_exemptions|Anti-cirumvention]] clauses which tell us that it is against the law to break copyright protection mechanisms (even if it is for legal purposes). The MPAA have used this power in the past to sue the makers of De-CSS (The copy protection scheme used in early DVD's). The AES Key that Rockstar used in GTA IV is technically an anti-circumvention measure and so cannot be posted here lest GTAMods Wiki be subject to legal ramifications. However since it is available in GTA IV's own binary a lot of people have just read it directly out of the actual executable (the offsets are posted in the section above). This doesn't only apply to people in the United States though, plenty of other countries have made their own legislation to the same effect, and many others have signed Free Trade Agreements with the United States that shoehorn the necessary DMCA provisions into the countries own legislation. Countries that have taken part in Free Trade Agreements include Australia, South Korea and The United Kingdom.&lt;br /&gt;
&lt;br /&gt;
Although other laws contradict this. For example in most countries reverse engineering for the purpose of interoperability (what most people who use the key try to achieve) transcends the anti-circumvention measures proposed by the DMCA. Although the legal issue still remains unclear most modders and site owners choose to be on the side of caution.&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
&lt;br /&gt;
Links to detailed explanations of the several hash and encryption algorithms on wikipedia:&lt;br /&gt;
* [[Wikipedia:SHA1|SHA1]]&lt;br /&gt;
* [[Wikipedia:CRC32|CRC32]]&lt;br /&gt;
* [[Wikipedia:Jenkins_hash_function#one-at-a-time|Jenkins One-at-a-time Hash]]&lt;br /&gt;
* [[Wikipedia:Advanced_Encryption_Standard|AES Encryption]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{SA-navi}}&lt;br /&gt;
{{GTA4-navi}}&lt;/div&gt;</summary>
		<author><name>AkifIe47</name></author>
		
	</entry>
</feed>