Crypto plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
Line 30: Line 30:
</highlight-nsis>
</highlight-nsis>
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 md5deep.  For example I generated notepad md5 checksum by doing the following in the [[Windows Command Line]]:
md5deep.exe "C:\Windows\notepad.exe" > hash.txt
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>
Crypto::HashFile "MD5" "$WINDIR\notepad.exe"
Pop $0
StrCmp $0 "ff7f14fda901090e337488a1900e3660" Continue
MessageBox MB_OK|MB_TOPMOST|MB_SETFOREGROUND|MB_ICONSTOP "ERROR: notepad.exe has been changed!!!"
Quit
Continue:
</highlight-nsis>


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

Revision as of 22:24, 12 August 2007

Author: GAG (talk, contrib)


Links

Zip.gif cryptoplg11.zip (43 KB) (plugin dll + readme + examples)

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

If you would like to create a hash of your files to be compared to then use md5deep to create your hash and then compare your hash (generated by Crypto plugin) to the hash you generated using md5deep. For example I generated notepad md5 checksum by doing the following in the Windows Command Line:

md5deep.exe "C:\Windows\notepad.exe" > hash.txt

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:

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