<?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%3Amd5memory</id>
	<title>Lua:md5memory - 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%3Amd5memory"/>
	<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:md5memory&amp;action=history"/>
	<updated>2026-05-21T18:59: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:md5memory&amp;diff=7775&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:md5memory&amp;diff=7775&amp;oldid=prev"/>
		<updated>2025-12-04T14:32:52Z</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''' md5memory(''address'', ''size'') ''':''' string&lt;br /&gt;
&lt;br /&gt;
Calculates and returns the MD5 checksum of a block of memory starting at the specified address. The result is returned as a lowercase hexadecimal string (32 hex characters). This is useful for integrity checks of memory regions, detecting runtime modifications, or comparing memory snapshots.&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: 70%;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
| address&lt;br /&gt;
| number|[[CEAddressString]] or Integer&lt;br /&gt;
| Start address of the memory block to hash.&lt;br /&gt;
|-&lt;br /&gt;
| size&lt;br /&gt;
| number&lt;br /&gt;
| Number of bytes to read from &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; and include in the hash.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
A string containing the MD5 hash of the memory block 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 reads &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; raw bytes starting at &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;, computes the MD5 digest over those bytes, and returns the digest formatted as a 32-character lowercase hexadecimal string. If the memory region cannot be read (invalid address, insufficient permissions, or target process not available), 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 with numeric address&lt;br /&gt;
local hash = md5memory(0x401000, 1024)&lt;br /&gt;
print(&amp;quot;MD5: &amp;quot; .. hash)  -- e.g. MD5: 9e107d9d372bb6826bd81d3542a419d6&lt;br /&gt;
&lt;br /&gt;
-- Using a module+offset string&lt;br /&gt;
local hash2 = md5memory(&amp;quot;kernel32.dll+0x1234&amp;quot;, 256)&lt;br /&gt;
print(&amp;quot;Region MD5: &amp;quot; .. hash2)&lt;br /&gt;
&lt;br /&gt;
-- Output:&lt;br /&gt;
-- MD5: a754c02f5e872ca0008b37755928a914 &lt;br /&gt;
-- Region MD5: 215a614d8b4156943fe865bb7d5e2c8c &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* The function hashes the raw bytes read from memory; CPU endianness or text encoding does not affect the MD5 result.&lt;br /&gt;
* Reading large regions can be slow and may consume significant memory depending on implementation; consider hashing in chunks if available.&lt;br /&gt;
* MD5 is not collision-resistant; do not rely on MD5 where collision resistance is required.&lt;br /&gt;
* When comparing MD5 strings, normalize case (lowercase) or use a case-insensitive comparison.&lt;br /&gt;
* Permission or process-targeting issues can prevent reading memory; ensure the correct process/context is selected before calling the function.&lt;/div&gt;</summary>
		<author><name>Leunsel</name></author>
		
	</entry>
</feed>