Current time: 05-06-2024, 10:22 PM Hello There, Guest! (LoginRegister)


Post Reply 
copy mysql user password ? (sqlu_pass)
Author Message
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #4
RE: copy mysql user password ? (sqlu_pass)
You can do it with the following functions (php):
Code:
function decrypt_db_password ($db_pass, $ispcp_db_pass_key, $ispcp_db_pass_iv) {
        if ($db_pass == '')
                return '';

        if (extension_loaded('mcrypt') || @dl('mcrypt.' . PHP_SHLIB_SUFFIX)) {
                $text = @base64_decode($db_pass . "\n");
                // Open the cipher
                $td = @mcrypt_module_open ('blowfish', '', 'cbc', '');
                // Create key
                $key = $ispcp_db_pass_key;
                // Create the IV and determine the keysize length
                $iv = $ispcp_db_pass_iv;

                // Intialize encryption
                @mcrypt_generic_init ($td, $key, $iv);
                // Decrypt encrypted string
                $decrypted = @mdecrypt_generic ($td, $text);
                @mcrypt_module_close ($td);

                // Show string
                return trim($decrypted);
        } else {
                die();
        }
}

function encrypt_db_password($db_pass, $ispcp_db_pass_key, $ispcp_db_pass_iv){
        if (extension_loaded('mcrypt') || @dl('mcrypt.' . PHP_SHLIB_SUFFIX)) {
                $td = @mcrypt_module_open (MCRYPT_BLOWFISH, '', 'cbc', '');
                // Create key
                $key = $ispcp_db_pass_key;
                // Create the IV and determine the keysize length
                $iv = $ispcp_db_pass_iv;

                //compatibility with used perl pads
                $block_size=@mcrypt_enc_get_block_size($td);
                $strlen=strlen($db_pass);

                $pads=$block_size-$strlen % $block_size;

                for ($i=0; $i<$pads;$i++){
                        $db_pass.=" ";
                }
                // Intialize encryption
                @mcrypt_generic_init ($td, $key, $iv);
                //Encrypt string
                $encrypted = @mcrypt_generic ($td, $db_pass);
                @mcrypt_generic_deinit($td);
                @mcrypt_module_close($td);

                $text = @base64_encode("$encrypted");
                $text=trim($text);
                return $text;
        } else {
                die("ERROR: The php-extension 'mcrypt' not loaded!");
        }
}
(This post was last modified: 02-07-2010 04:24 AM by kilburn.)
02-07-2010 04:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
RE: copy mysql user password ? (sqlu_pass) - kilburn - 02-07-2010 04:23 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)