Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Blowfish Encryption Dll + Functions


  • Please log in to reply
28 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
(Thanx corrupt for making this possible! ...I've used the info u gave to make these funtions)

Here's a small (10 kb) dll file which can be used for the fast and secure blowfish encryption.

The functions are:
EncPass (used to encrypt a password to make it a lot more secure)
Encrypt
Decrypt

Dll

Data = my test data
pw = password

pw := encpass(pw)
msgbox %pw%



res := encrypt(data,pw)
msgbox %res%

res := decrypt(res,pw)
msgbox %res%




;used to encrypt a password to make it a lot more secure
EncPass(Key)
{
	;VarSetCapacity(Output, 2048) 

	ATrim = %A_AutoTrim%
	AutoTrim, Off

	Ret := DllCall("blowfish.dll\Encpass", "str", "aircdll.dll", "str", "Encpass", "str", Key, "Cdecl")
	StringTrimLeft, Key, Key, 4

	AutoTrim, %ATrim%
	Return Key
}



Encrypt(Data,Key)
{
	;VarSetCapacity(Output, 2048) 

	ATrim = %A_AutoTrim%
	AutoTrim, Off

	Output = %Key%%A_Space%%Data%
	Ret := DllCall("blowfish.dll\Encrypt", "str", "aircdll.dll", "str", "Encrypt", "str", Output, "Cdecl")
	StringTrimLeft, Output, Output, 4

	AutoTrim, %ATrim%
	Return Output
}



Decrypt(Data,Key)
{
	;VarSetCapacity(Output, 2048) 

	ATrim = %A_AutoTrim%
	AutoTrim, Off

	Output = %Key%%A_Space%%Data%
	Ret := DllCall("blowfish.dll\Decrypt", "str", "aircdll.dll", "str", "Decrypt", "str", Output, "Cdecl")
	StringTrimLeft, Output, Output, 4 

	AutoTrim, %ATrim%
	Return Output
}

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Nice and easy! Thanks for sharing it!

In case you trust Microsoft, Windows (since 2000) provides built in functions for that, that is, no external DLL is needed. The method was triple DES, and since XP SP2, I think, it is AES. I have not tried this yet, so I am not sure if it works from AHK. Because of the different cipher, it is just another alternative.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
Looks great Rajat :) .

I probably should have mentioned that it may not hurt to add a test after a call to the dll to make sure the output started with +OK . There are a couple other strings that could be output instead if a function fails for some reason. Checking the first character might be enough since the first character seems to start with - if a function fails.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
@corrupt
yes basic error checking should be there... i'll put it in soon. thanx!

@laszlo
i did have a brief look into those functions (crypt32.dll i reckon?) but it looked like lot of work and triple DES is not as fast as blowfish. i think there are a couple more crypting/hashing methods built-in too ...including md5.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
laszlo, what'd be the best way to get around the null byte problem here? ... is parsing one byte at a time the only way?

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Dll calls could return binary buffers (with NULL bytes), which can be easily read/written from/to disk with the binary buffer file I/O functions. If you don’t do anything else with the binary data, but read/write, copy or compare, that is sufficient.

However, if you want to encrypt data and be able to process it within AHK, like paste it into message board windows, or copy it from edit controls, you need the text based crypto functions.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Thanx! :)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Loriss
  • Members
  • 62 posts
  • Last active: Oct 09 2008 05:23 PM
  • Joined: 26 Jul 2004
With the Norton AntiVirus+Internet Security
the Blowfish Dll is see how a Troian.
Loriss

AHKnow*
  • Guests
  • Last active:
  • Joined: --
I confirm this.

Norton sees the blowfish dll as a IRC Trojan.

Anybody have anymore info about this?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Probably another example in an enormous list of false positives generated by overzealous security software. Other than ignoring the virus report, I think the only remedy is to ask the company to fix their scanner.

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

overzealous security software

Virus checkers search for bit patterns, the virus signatures in executable files (or in whatever you chose). The length of these patterns is chosen as a trade off. Shorter ones make the search faster and allow many mutant viruses still to be caught, but result in more false alarms. It is impossible for the makers of the virus signature lists to test every possible innocent program, so there will be always false positives.

M'o
  • Members
  • 10 posts
  • Last active: Feb 14 2012 10:57 AM
  • Joined: 09 Mar 2006
Hi together,

since today is the blowfish.dll from the download link in the first post by trend micro as a virus classificated.

I can't find the home of the blowfish.dll, google delivers any results, but not the home.

Who can help?

Thanks.

M'o

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

I can't find the home of the blowfish.dll, google delivers any results, but not the home.

Who can help?

get the file here

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


M'o
  • Members
  • 10 posts
  • Last active: Feb 14 2012 10:57 AM
  • Joined: 09 Mar 2006
Hi Rajat,

is this version newer as the in the first post? The problem is, that trend micro virus scan in the dll find a pattern like a irc virus.

But in my company i can't disable the virus scan or add the blowfish.dll to exceptions...

greeting from germany
M'o

  • Guests
  • Last active:
  • Joined: --
Someone might have used the dll with thier irc bot and the av company flags the dll as a virus.