Crypto plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
Line 32: Line 32:
Supported algorithms: MD5|SHA1|MD2|MD4
Supported algorithms: MD5|SHA1|MD2|MD4


If you would like to create a hash of your files to be compared to then use [http://sourceforge.net/project/showfiles.php?group_id=67079&package_id=65262&release_id=530163 md5deep] to create your hash and then compare your hash (generated by Crypto plugin) to the hash you generated using [http://sourceforge.net/project/showfiles.php?group_id=67079&package_id=65262&release_id=530163 md5deep]. For example I generated notepad md5 checksum by doing the following in the [[Windows Command Line]]:
Calculate the hash of the file you want checked using the Hash Calculator ([http://forums.winamp.com/attachment.php?s=&postid=1346396 hashcalc.zip]).
md5deep.exe "C:\Windows\notepad.exe" > hash.txt
From there I was able to use Crypto to ensure that notepad hasn't changed:
Then I opened hash.txt and it looked like
ff7f14fda901090e337488a1900e3660  C:\Windows\notepad.exe
So from there I was able to use Crypto to ensure that notepad hasn't changed:
<highlight-nsis>
<highlight-nsis>
Crypto::HashFile "MD5" "$WINDIR\notepad.exe"  
Crypto::HashFile "MD5" "$WINDIR\notepad.exe"  
Pop $0
Pop $0
StrCmp $0 "ff7f14fda901090e337488a1900e3660" Continue
StrCmp $0 "FF7F14FDA901090E337488A1900E3660" +3
MessageBox MB_OK|MB_TOPMOST|MB_SETFOREGROUND|MB_ICONSTOP "ERROR: notepad.exe has been changed!!!"
MessageBox MB_OK|MB_TOPMOST|MB_SETFOREGROUND|MB_ICONSTOP "ERROR: notepad.exe has been changed!!!"
Quit
Quit
Continue:
</highlight-nsis>
</highlight-nsis>


[[Category:Plugins]]
[[Category:Plugins]]

Revision as of 23:26, 12 August 2007

Author: GAG (talk, contrib)


Links

Zip.gif cryptoplg11.zip (43 KB) (plugin dll + readme + examples)
Zip.gif hashcalc.zip (30 KB) (Calculates the hash for Strings or specified files)

Forum Thread

Introduction

Version: 1.1.

This plugin provides you cryptographic interface using CryptoAPI. Using this plugin you can get common cryptographic hashes like MD5, SHA1, MD2, MD4.

Plugin DLL size: 3 660 bytes (not packed), 2 886 bytes (upx packed)

How to use

String Hash

Crypto::HashData "MD5" "String to be hashed"
Pop $0

Supported algorithms: MD5|SHA1|MD2|MD4

File Hash

Crypto::HashFile "MD5" "$WINDIR\notepad.exe"
Pop $0

Supported algorithms: MD5|SHA1|MD2|MD4

Calculate the hash of the file you want checked using the Hash Calculator (hashcalc.zip). From there I was able to use Crypto to ensure that notepad hasn't changed:

Crypto::HashFile "MD5" "$WINDIR\notepad.exe" 
Pop $0
StrCmp $0 "FF7F14FDA901090E337488A1900E3660" +3
MessageBox MB_OK|MB_TOPMOST|MB_SETFOREGROUND|MB_ICONSTOP "ERROR: notepad.exe has been changed!!!"
Quit