AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [ANY] MD5 Stocks for both files and strings. (https://forums.alliedmods.net/showthread.php?t=303868)

thomasjosif 12-25-2017 13:06

[ANY] MD5 Stocks for both files and strings.
 
Couldn't find a way to get the MD5 hash of a file without extensions, so I did it myself. Someone could probably find it useful. (I'm using it to verify downloaded files.) It could be improved but was short on time.

Note: All I did was split up the MD5 function for it to be able to work with files.

Have fun.

PHP Code:

// Quick test of md5 functions.
#include <sourcemod>
#include <md5stocks>

public void OnPluginStart()
{
    
char path[PLATFORM_MAX_PATH];
    
char md5[512];
    
BuildPath(Path_SMpathsizeof(path), "/plugins/md5.smx");
    if(
MD5_File(pathmd5sizeof(md5)))
    {
        
PrintToServer("****** MD5 FILE ******");
        
PrintToServer(md5);
        
PrintToServer("****** MD5 FILE ******");
    }
    else
        
PrintToServer("**** FILE NOT FOUND ****");


include file

lake393 04-09-2018 01:07

Re: [ANY] MD5 Stocks for both files and strings.
 
1 Attachment(s)
Fixed issue with MD5_File not working on Windows machines.

Updated include file attached.

nosoop 04-09-2018 05:09

Re: [ANY] MD5 Stocks for both files and strings.
 
To clarify on the MD5_File issue, OpenFile is implied to open in text mode by default.

This is an issue on Windows as any read newline \n characters will be read as the Windows \r\n line ending, causing the hash to be different.

The only change was to explicitly open the file in binary read mode "rb" instead.


All times are GMT -4. The time now is 22:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.