Blowfish++ plug-in

From NSIS Wiki
Jump to navigationJump to search
Author: Cubique (talk, contrib)


Compatibility

This plug-in uses an implementation of Blowfish that is broken on little-endian machines. This means that it will not be interoperable with other implementations of Blowfish, such as those in PHP and Java. For more information and a fix, see this post.

Links

File:Blowfish++.zip - source code

File:BlowfishDLL.7z - DLL plug-in library

Description

A NSIS plug-in that allow you to encrypt/decrypt a message using the Blowfish algorithm. It's just a simple DLL file (copy it to your NSIS Plugin folder) that exports two NSIS-aware functions:

  • encrypt
  • decrypt
C++ source code included (it is also my 1st C++ program and 1st NSIS plug-in I ever wrote, too).
It was tested with NSIS v2.45 but should work with some older versions too.

Parts of these sample programs are derivative works based on the work of the following individuals:

DLL Functions

blowfish::encrypt

Encrypts an text using a password key.

Syntax

blowfish::encrypt <text-to-encrypt> <password-key>

Parameters

  • <text-to-encrypt> : a string of chars to be encrypted
  • <password-key> : the password used to encrypt the string; password-key must be 8-56 bytes long

Return Value

  • On success: first item on stack will be "0", next item on the stack will be the encrypted text.
  • On failure: first item on stack will be "1", next item on the stack will be the error message.

Example

  blowfish::encrypt "the text I want to encrypt" "a strong password"
  Pop $0                     ; 0 on success, 1 on failure
  Pop $1                     ; encrypted message on success, error message on failure

blowfish::decrypt

Decrypts an Blowfish encrypted text using the corresponding password key.

Syntax

blowfish::decrypt <text-to-decrypt> <password-key>

Parameters

  • <text-to-decrypt> : a string of chars to be decrypted
  • <password-key> : the password used to decrypt the string; password-key must be 8-56 bytes long

Return Value

  • On success: first item on stack will be "0", next item on the stack will be the decrypted text.
  • On failure: first item on stack will be "1", next item on the stack will be the error message.

Example

  blowfish::decrypt "9I0JMuUoBQjErC3t5hVRLToinZwFTUd7EXwc2u8osV8=" "a strong password"
  Pop $0                     ; 0 on success, 1 on failure
  Pop $1                     ; encrypted message on success, error message on failure

Version History

Version: 0.1.beta 06.Dec.2009

Credits

Plug-in created by Cubique.