Security is a big issue nowadays and if you are a frequent IRC user like me, its not always easy to chat securely. Luckily most servers support SSL connections but not all. For the ones that don’t support it or for the people that are completely paranoid there is another way to encrypt your communication which is the blowfish algorithm. This algorithm will encrypt your data using a secret key. A second party can decrypt it using the same secret key. For IRC there is a plugin called fish which can be used by several IRC clients.

My problem was that my IRC bot didn’t support blowfish so it couldn’t be used in encrypted channels. There isn’t a straight forward package in Perl (my bot is written in perl) for encrypting/decrypting blowfish on IRC so I had to fabricate one. The package is available below.

Usage:

    # package
    use Blowfish;
    
    # encrypt
    my $encrypted = Blowfish::encrypt('this is plaintext', 'secret_key');
    
    # decrypt
    my $decrypted = Blowfish::decrypt($encrypted, 'secret_key');

    # prints 'hwwnV0UVbDE1z2N0E0AZlBT/Mi965/OLpHf/'
    print $encrypted ."\n";
    
    # prints 'this is plaintext'
    print $decrypted ."\n";

    # send to irc channel
    print $ircSocket 'PRIVMSG #channel :+OK'. $encrypted;

Update: Fixed a bug when decrypting, more details
Download: Blowfish_v1_0_1.pm.zip (1,6K)

Suggestions and feedback are more then welcome!