Search the Community
Showing results for tags 'blowfish'.
-
I am just curious, is this the correct way to implement blowfish encryption? class: <?php /* * @package "Gludoe CMS" * @version 1.0.1 * @authors "Robert Pettet" * @support https://www.gludoe.com/ * @licence https://www.gludoe.com/commons/licence-1.0.0.txt */ if (!defined('_ROOT')) exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found')); class Blowfish { private $key; private $iv; public function __construct($key, $iv) { $this->key = $key; $this->iv = $iv; } public function encrypt($data) { return mcrypt_encrypt(MCRYPT_BLOWFISH, $this->key, $data, MCRYPT_MODE_CBC, $this->iv); } public function decrypt($data) { return mcrypt_decrypt(MCRYPT_BLOWFISH, $this->key, $data, MCRYPT_MODE_CBC, $this->iv); } } ?> example: $blowfish = new blowfish('DfRgBWE4Y4T7UgTWEdFP1Y','85440934'); $data = $blowfish->encrypt('testString'); echo $blowfish->decrypt($data); //Output: testString
-
I'm trying to use a simple encryption class and getting 500 errors. I was able to pinpoint the error to a check for CRYPT_BLOWFISH: if( CRYPT_BLOWFISH == 1 ) { // .... } I thought all php 5.3.X installations were supposed to have CRYPT_BLOWFISH defined. What can I do? The encryption class needs it, and I'm hoping there's an easy fix.