<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cheatengine.org/index.php?action=history&amp;feed=atom&amp;title=Lua%3Amd5file</id>
	<title>Lua:md5file - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cheatengine.org/index.php?action=history&amp;feed=atom&amp;title=Lua%3Amd5file"/>
	<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:md5file&amp;action=history"/>
	<updated>2026-04-14T19:41:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.cheatengine.org/index.php?title=Lua:md5file&amp;diff=7772&amp;oldid=prev</id>
		<title>Leunsel: Initial page creation.</title>
		<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:md5file&amp;diff=7772&amp;oldid=prev"/>
		<updated>2025-12-03T15:49:58Z</updated>

		<summary type="html">&lt;p&gt;Initial page creation.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Lua]]&lt;br /&gt;
{{NeedWork}}&lt;br /&gt;
&lt;br /&gt;
'''function''' md5file(''pathToFile'') ''':''' string&lt;br /&gt;
&lt;br /&gt;
Calculates and returns the MD5 checksum of a file's contents. The result is returned as a lowercase hexadecimal string (32 hex characters). This is useful for integrity checks, detecting file changes, or verifying downloads.&lt;br /&gt;
&lt;br /&gt;
=== Function Parameters ===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Parameter&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Type&lt;br /&gt;
!style=&amp;quot;width: 80%;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
| pathToFile&lt;br /&gt;
| string&lt;br /&gt;
| Path to the file to be hashed. Use an absolute or relative path. On Windows, backslashes (&amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;) are allowed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
A string containing the MD5 hash of the file in lowercase hexadecimal (e.g. &amp;lt;code&amp;gt;9e107d9d372bb6826bd81d3542a419d6&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
The function opens the specified file, reads its bytes, computes the MD5 digest over the file contents, and returns the digest formatted as a 32-character hexadecimal string. If the file cannot be opened or read, the function may raise an error.&lt;br /&gt;
&lt;br /&gt;
=== Usage Examples ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- Simple usage&lt;br /&gt;
local hash = md5file(&amp;quot;C:\\Games\\mygame.exe&amp;quot;)&lt;br /&gt;
print(&amp;quot;MD5: &amp;quot; .. hash)  -- e.g. MD5: 9e107d9d372bb6826bd81d3542a419d6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Script Error:Unable to open file &amp;quot;C:\path\to\file.bin&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* The function reads the raw bytes of the file; text encoding does not affect the hash.&lt;br /&gt;
* For very large files the operation can be slow and use memory depending on implementation.&lt;br /&gt;
* MD5 collisions are possible; do not use MD5 when collision resistance is required.&lt;br /&gt;
* When comparing MD5 strings, normalize case (lowercase) or use a case-insensitive comparison.&lt;/div&gt;</summary>
		<author><name>Leunsel</name></author>
		
	</entry>
</feed>