error = "mcrypt"; return(FALSE); } $data_enc = bin2hex(mcrypt_ecb(MCRYPT_BLOWFISH, $enc_key, $data_clear, MCRYPT_ENCRYPT, $iv)); return($data_enc); } // function encrypt_data($data_clear, $enc_key) function decryptSNAFU_data($data_enc) { $enc_key = Privy::$ek; if (trim($data_enc) == "") { return ($data_enc); } if(!$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB), MCRYPT_RAND)) { $this->error = "mcrypt"; return(FALSE); } $data_enc = $this->hex2bin($data_enc); $data_dec = mcrypt_ecb(MCRYPT_BLOWFISH, $enc_key, $data_enc, MCRYPT_DECRYPT, $iv); if(substr($data_dec, 0, 1) == "3") // && substr($cc_num_dec, 15, 1) == "0") { // TRUNCATE ALL AMEX CARDS TO 15 CHARS $data_dec = substr($data_dec, 0, 15); } return ($data_dec); } // function decrypt($cc_num_enc, $key) function hex2bin($hex_data) { $len = strlen($hex_data); return pack("H" . $len, $hex_data); } // function hex2bin($hex_data) } // class encryption ?>