Blowfish plug-in: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (→Helper Macro (optional): Removed "Artifact") |
|||
(One intermediate revision by the same user not shown) | |||
Line 66: | Line 66: | ||
MessageBox MB_OK "Decrypted string is $8" | MessageBox MB_OK "Decrypted string is $8" | ||
</highlight-nsis> | </highlight-nsis> | ||
== Helper Macro (optional) == | |||
<highlight-nsis>## BlowFish Plugin Macro | |||
## --------------------- | |||
## Syntax: | |||
## ${BlowFish_Encrypt} {returnVariable | ""} <StringToEncrypt> <EncryptionKey> | |||
## ${BlowFish_Decrypt} {returnVariable | ""} <StringToDecrypt> <DecryptionKey> | |||
!ifmacrondef _BlowFish | |||
!define BlowFish_Decrypt `!insertmacro _BlowFish Decrypt` | |||
!define BlowFish_Encrypt `!insertmacro _BlowFish Encrypt` | |||
!macro _BlowFish _cmd _retVar _Data _Key | |||
!if `${_retVar}` != `$8` | |||
Push $8 | |||
!endif | |||
BlowFish::${_cmd} `${_Data}` `${_Key}` | |||
!if `${_retVar}` != `$8` | |||
Exch $8 | |||
!if `${_retVar}` != `` | |||
Pop ${_retVar} | |||
!endif | |||
!endif | |||
!macroend | |||
!endif | |||
## Example using the $0 register | |||
${BlowFish_Encrypt} $0 "Top Secret" "password" | |||
DetailPrint "Encrypted: $0" | |||
${BlowFish_Decrypt} $0 $0 "password" | |||
DetailPrint "Decrypted: $0" | |||
## Example using the stack, notice | |||
${BlowFish_Encrypt} "" $0 "password" | |||
Pop $1 | |||
DetailPrint "$0 => $1" | |||
${BlowFish_Decrypt} "" $1 "password" | |||
Pop $2 | |||
DetailPrint "$1 => $2"</highlight-nsis> | |||
== Versions History == | == Versions History == | ||
Line 74: | Line 114: | ||
== Credits == | == Credits == | ||
Plug-in created by [[User:yehiaeg|yehiaeg]]. | Plug-in created by [[User:yehiaeg|yehiaeg]].<br /> | ||
Macro created by [[User:Zinthose|Zinthose]]. | |||
[[Category:Plugins]] | [[Category:Plugins]] |
Latest revision as of 19:15, 19 November 2010
Links
Download link:
Blowfish.zip (14 KB)
Description
Version: 1.0.
Can encrypt a value using the Blowfish algorithm from a string w/ password. The password can be used later to unlock the original string in the decryption process. No source code is included.
DLL Functions
blowfish::encrypt
Encrypts data using the Blowfish algorithm.
Syntax
blowfish::encrypt "String" "Password"
Parameters
- String
- String to be encrypted.
- Password
- Password to be used in decryption to get the "String" value back.
Return Value
Encrypted value to the variable "$8".
Example
blowfish::encrypt "secret" "password" MessageBox MB_OK "Encrypted string is $8"
blowfish::decrypt
Decrypts data using the Blowfish algorithm.
Syntax
blowfish::decrypt "EncryptedString" "Password"
Parameters
- EncryptedString
- String to be decrypted.
- Password
- Password to restore the original "String" value from the encryption process.
Return Value
Decrypted value to the variable "$8".
Example
blowfish::decrypt $8 "password" MessageBox MB_OK "Decrypted string is $8"
Helper Macro (optional)
## BlowFish Plugin Macro ## --------------------- ## Syntax: ## ${BlowFish_Encrypt} {returnVariable | ""} <StringToEncrypt> <EncryptionKey> ## ${BlowFish_Decrypt} {returnVariable | ""} <StringToDecrypt> <DecryptionKey> !ifmacrondef _BlowFish !define BlowFish_Decrypt `!insertmacro _BlowFish Decrypt` !define BlowFish_Encrypt `!insertmacro _BlowFish Encrypt` !macro _BlowFish _cmd _retVar _Data _Key !if `${_retVar}` != `$8` Push $8 !endif BlowFish::${_cmd} `${_Data}` `${_Key}` !if `${_retVar}` != `$8` Exch $8 !if `${_retVar}` != `` Pop ${_retVar} !endif !endif !macroend !endif ## Example using the $0 register ${BlowFish_Encrypt} $0 "Top Secret" "password" DetailPrint "Encrypted: $0" ${BlowFish_Decrypt} $0 $0 "password" DetailPrint "Decrypted: $0" ## Example using the stack, notice ${BlowFish_Encrypt} "" $0 "password" Pop $1 DetailPrint "$0 => $1" ${BlowFish_Decrypt} "" $1 "password" Pop $2 DetailPrint "$1 => $2"
Versions History
- 1.0 - 19/Jan/2005
- First version.