<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/FileGetHash?action=history&amp;feed=atom</id>
	<title>FileGetHash - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/FileGetHash?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FileGetHash&amp;action=history"/>
	<updated>2026-05-07T14:32:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FileGetHash&amp;diff=82257&amp;oldid=prev</id>
		<title>Botder: Created page with &quot;__NOTOC__ {{Server client function}}  {{Added feature/item|1.6.1|1.6.0|23289| This function returns a hash of the entire file in the specified algorithm. This function ''does not'' move the file pointer/position. Beware though, there will always be a minuscule period of time between checking the hash and loading the contents of the file, which can be abused by a potential attacker to modify the contents. }}  ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt; nil|string fileGetHash...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FileGetHash&amp;diff=82257&amp;oldid=prev"/>
		<updated>2025-07-23T18:48:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ {{Server client function}}  {{Added feature/item|1.6.1|1.6.0|23289| This function returns a hash of the entire file in the specified algorithm. This function &amp;#039;&amp;#039;does not&amp;#039;&amp;#039; move the file pointer/position. Beware though, there will always be a minuscule period of time between checking the hash and loading the contents of the file, which can be abused by a potential attacker to modify the contents. }}  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; nil|string fileGetHash...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
{{Added feature/item|1.6.1|1.6.0|23289|&lt;br /&gt;
This function returns a hash of the entire file in the specified algorithm. This function ''does not'' move the file pointer/position. Beware though, there will always be a minuscule period of time between checking the hash and loading the contents of the file, which can be abused by a potential attacker to modify the contents.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
nil|string fileGetHash ( file theFile, string algorithm [, table options ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[file]]:getHash}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theFile:''' A handle to the file you wish to get the hash from. Use [[fileOpen]] to obtain this handle.&lt;br /&gt;
*'''algorithm''': A string which must be one of these: &amp;quot;md5&amp;quot;, &amp;quot;sha1&amp;quot;, &amp;quot;sha224&amp;quot;, &amp;quot;sha256&amp;quot;, &amp;quot;sha384&amp;quot;, &amp;quot;sha512&amp;quot;, &amp;quot;hmac&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Optional arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''options''': A table with options and other necessary data for the algorithm, as detailed below.&lt;br /&gt;
&lt;br /&gt;
===Options for each algorithm===&lt;br /&gt;
* ''hmac'' ([https://en.wikipedia.org/wiki/HMAC HMAC])&lt;br /&gt;
** '''key''': a key to encode the input with.&lt;br /&gt;
** '''algorithm''': a string which must be one of these: &amp;quot;md5&amp;quot;, &amp;quot;sha1&amp;quot;, &amp;quot;sha224&amp;quot;, &amp;quot;sha256&amp;quot;, &amp;quot;sha384&amp;quot;, &amp;quot;sha512&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the hash of the entire file on success, and ''nil'' on failure.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example opens the code.lua file, computes the hash with every algorithm, and then displays them.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local handle = fileOpen(&amp;quot;code.lua&amp;quot;, true)&lt;br /&gt;
local hashMD5 = fileGetHash(handle, &amp;quot;md5&amp;quot;)&lt;br /&gt;
local hashSHA1 = fileGetHash(handle, &amp;quot;sha1&amp;quot;)&lt;br /&gt;
local hashSHA224 = fileGetHash(handle, &amp;quot;sha224&amp;quot;)&lt;br /&gt;
local hashSHA256 = fileGetHash(handle, &amp;quot;sha256&amp;quot;)&lt;br /&gt;
local hashSHA384 = fileGetHash(handle, &amp;quot;sha384&amp;quot;)&lt;br /&gt;
local hashSHA512 = fileGetHash(handle, &amp;quot;sha512&amp;quot;)&lt;br /&gt;
local hashHMAC = fileGetHash(handle, &amp;quot;hmac&amp;quot;, { algorithm = &amp;quot;sha256&amp;quot;, key = &amp;quot;blue apple tree&amp;quot; })&lt;br /&gt;
fileClose(handle)&lt;br /&gt;
&lt;br /&gt;
iprint(&amp;quot;MD5&amp;quot;, hashMD5)&lt;br /&gt;
iprint(&amp;quot;SHA1&amp;quot;, hashSHA1)&lt;br /&gt;
iprint(&amp;quot;SHA224&amp;quot;, hashSHA224)&lt;br /&gt;
iprint(&amp;quot;SHA256&amp;quot;, hashSHA256)&lt;br /&gt;
iprint(&amp;quot;SHA384&amp;quot;, hashSHA384)&lt;br /&gt;
iprint(&amp;quot;SHA512&amp;quot;, hashSHA512)&lt;br /&gt;
iprint(&amp;quot;HMAC-SHA256&amp;quot;, hashHMAC )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{File functions}}&lt;/div&gt;</summary>
		<author><name>Botder</name></author>
	</entry>
</feed>