Skip to content

A naïve implementation of the Blowfish encryption algorithm in PHP

Notifications You must be signed in to change notification settings

lombizani/blowPHish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

blowPHish.php

A naïve Blowfish implementation in PHP by Carlos De Bernardis

How to run

You need PHP-CLI > 5.5 to run this program.

$ php -f blowPHish.php --

Command-line arguments: -e - Flags encryption. Must be accompanied by -k, -i and -o. -d - Flags decryption. Must be accompanied by -k, -i and -o. -g - Flags key generation, must be followed by desired key size and -k. -k - Specifies which file to read/write key from/to. -i - Specifies file from which data to encrypt/decrypt shall be read. -o - Specifies file to which decrypted/encrypted data will be written.

Implementation details

Keys are randomly generated using Blowfish itself (in counter mode) and stored encrypted with Blowfish by using a SHA1 hash of a user-provided passphrase as key. The passphrase must always be supplied for both encryption and decryption.

I have also chosen to encrypt data in CBC mode to protect it from being rearranged. The encrypted file includes the initialization vector in the beginning (it is obviously stripped after decryption).

Issues

It sometimes appends a few null characters to the end of the decrypted file because I haven't yet implemented a way to save the original file's length.

About

A naïve implementation of the Blowfish encryption algorithm in PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages