When I include these 2 functions on a page I seem to get this error: Warning: Cannot modify header information - headers already sent by (output started at /home/vmtgiqlm/public_html/fftest/encryption.php:43) in /home/vmtgiqlm/public_html/fftest/check_login.php on line 40

I don't know why that would happen as these functions do not output any text. Anyway here are the encryption functions that I am using:

<?php

function sf_encrypt($input,$key){

        $input = str_replace("\n","",$input);
        $input = str_replace("\t","",$input);
        $input = str_replace("\r","",$input);
        $key = substr(md5($key),0,24);
        $td = mcrypt_module_open('tripledes', '', 'ecb', '');
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key, $iv);
        $encrypted_data = mcrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        
        return trim(chop(base64_encode($encrypted_data)));
        
}

function sf_decrypt($input,$key){

        $input = str_replace("\n","",$input);
        $input = str_replace("\t","",$input);
        $input = str_replace("\r","",$input);
        $input = trim(chop(base64_decode($input)));
        $td = mcrypt_module_open('tripledes', '', 'ecb', '');
        $key = substr(md5($key),0,24);
        $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init ($td, $key, $iv);
        $decrypted_data = mdecrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        
        return trim(chop($decrypted_data));
        
}

?>

I don't know what is going wrong but any help would be appreciated, Thanks

When I include these 2 functions on a page I seem to get this error: Warning: Cannot modify header information - headers already sent by (output started at /home/vmtgiqlm/public_html/fftest/encryption.php:43) in /home/vmtgiqlm/public_html/fftest/check_login.php on line 40

I don't know why that would happen as these functions do not output any text. Anyway here are the encryption functions that I am using:

<?php

function sf_encrypt($input,$key){

        $input = str_replace("\n","",$input);
        $input = str_replace("\t","",$input);
        $input = str_replace("\r","",$input);
        $key = substr(md5($key),0,24);
        $td = mcrypt_module_open('tripledes', '', 'ecb', '');
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key, $iv);
        $encrypted_data = mcrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        
        return trim(chop(base64_encode($encrypted_data)));
        
}

function sf_decrypt($input,$key){

        $input = str_replace("\n","",$input);
        $input = str_replace("\t","",$input);
        $input = str_replace("\r","",$input);
        $input = trim(chop(base64_decode($input)));
        $td = mcrypt_module_open('tripledes', '', 'ecb', '');
        $key = substr(md5($key),0,24);
        $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init ($td, $key, $iv);
        $decrypted_data = mdecrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        
        return trim(chop($decrypted_data));
        
}

?>

I don't know what is going wrong but any help would be appreciated, Thanks

send total code.

Thanks for the reply. I've sent you a private message including the rest of the code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.