Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:31:04+00:00 2026-05-26T14:31:04+00:00

Openfire stores encrypted passwords in a database using blowfish encryption. http://svn.igniterealtime.org/svn/repos/openfire/trunk/src/java/org/jivesoftware/util/Blowfish.java is the java

  • 0

Openfire stores encrypted passwords in a database using blowfish encryption.

http://svn.igniterealtime.org/svn/repos/openfire/trunk/src/java/org/jivesoftware/util/Blowfish.java is the java implementation for how encrypt / decrypt functions work in openfire.

My goal is to create new user entries in the database via PHP and MySQLI. All of the variations I’ve tried have yielded results that don’t match what already exists in the database. For example:

d3f499857b40ac45c41828ccaa5ee1f90b19ca4e0560d1e2dcf4a305f219a4a2342aa7364e9950db is one of the encrypted passwords. clear text, this is stackoverflow

I’ve tried a few variations:

echo mcrypt_cbc(MCRYPT_BLOWFISH, '1uY40SR771HkdDG', 'stackoverflow', MCRYPT_ENCRYPT, '12345678');
// result:  áë*sY¶nŸÉX_33ô

Another based on mcrypt blowfish php slightly different results when compared to java and .net

 $key = '1uY40SR771HkdDG';
 $pass = 'stackoverflow';
 $blocksize = mcrypt_get_block_size('blowfish', 'cbc'); // get block size
 $pkcs = $blocksize - (strlen($data) % $blocksize); // get pkcs5 pad length
 $data.= str_repeat(chr($pkcs), $pkcs); // append pkcs5 padding to the data

 // encrypt and encode
 $res = base64_encode(mcrypt_cbc(MCRYPT_BLOWFISH,$key, $pass, MCRYPT_ENCRYPT));
 echo $res;
 // result:  3WXKASjk35sI1+XJ7htOGw==

Any clever ideas, or any glaring problems? I simply want to implement Blowfish.encryptString() as referenced in the first link in this question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:31:05+00:00Added an answer on May 26, 2026 at 2:31 pm

    Here’s a class I made, it encrypts and decrypts properly.

    Note, you need to save / [pre/app]end the IV in order to reproduce results.

    Some test vectors for the java code would be nice.

    <?php
    
    /**
     * Emulate OpenFire Blowfish Class
     */
    class OpenFireBlowfish
    {
        private $key;
        private $cipher;
    
        function __construct($pass)
        {
            $this->cipher = mcrypt_module_open('blowfish','','cbc','');
            $this->key = pack('H*',sha1($pass));
        }
    
        function encryptString($plaintext, $iv = '')
        {
            if ($iv == '') {
                $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->cipher));
            }
            else {
                $iv = pack("H*", $iv);
            }
            mcrypt_generic_init($this->cipher, $this->key, $iv);
            $bs = mcrypt_enc_get_block_size($this->cipher); // get block size
            $plaintext = mb_convert_encoding($plaintext,'UTF-16BE'); // set to 2 byte, network order
            $pkcs = $bs - (strlen($plaintext) % $bs); // get pkcs5 pad length
            $pkcs = str_repeat(chr($pkcs), $pkcs); // create padding string
            $plaintext = $plaintext.$pkcs; // append pkcs5 padding to the data
            $result = mcrypt_generic($this->cipher, $plaintext);
            mcrypt_generic_deinit($this->cipher);
            return $iv.$result;
        }
    
        function decryptString($ciphertext)
        {
            $bs = mcrypt_enc_get_block_size($this->cipher); // get block size
            $iv_size = mcrypt_enc_get_iv_size($this->cipher);
            if ((strlen($ciphertext) % $bs) != 0) { // check string is proper size
                return false;
            }
            $iv = substr($ciphertext, 0, $iv_size); // retrieve IV
            $ciphertext = substr($ciphertext, $iv_size);
            mcrypt_generic_init($this->cipher, $this->key, $iv);
            $result = mdecrypt_generic($this->cipher, $ciphertext); // decrypt
            $padding = ord(substr($result,-1)); // retrieve padding
            $result = substr($result,0,$padding * -1); // and remove it
            mcrypt_generic_deinit($this->cipher);
            return $result;
        }
    
        function __destruct()
        {
            mcrypt_module_close($this->cipher);
        }
    }
    
    $enckey = "1uY40SR771HkdDG";
    $enciv = 'd3f499857b40ac45';
    $javastring = 'd3f499857b40ac45c41828ccaa5ee1f90b19ca4e0560d1e2dcf4a305f219a4a2342aa7364e9950db';
    
    $a = new OpenFireBlowfish($enckey);
    $encstring = bin2hex($a->encryptString('stackoverflow',$enciv));
    echo $encstring . "\n";
    echo $a->decryptString(pack("H*", $encstring)) . "\n";
    
    $b = new OpenFireBlowfish($enckey);
    echo $b->decryptString(pack("H*", $javastring)) . "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following this guide (http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/db-integration-guide.html) to integrate the Openfire server with and Sql Server
Have you developed for OpenFire (http://www.igniterealtime.org/)? How has your experience? pros/cons/comments, please. I'm evaluation
I setup a Openfire server with external MySQL database using the openfire_mysql.sql file from
We are using Openfire (Jabber) to enable chat and presence capabilities to our MMORPG.
when sending packet to openfire using Smack, i get error remote-server-not-found(404) . Can anyone
I'm using Openfire as an XMPP server, and it seems to be working great;
I'm using OpenFire server for instant messaging and JSJaC JavaScript library on the client.
I am using Smack API to connect to the Openfire server. I have successfully
I am working with Openfire with external MySQL database created with the default openfire_mysql.sql
I'm using openfire as XMPP server. Clients connect to it via BOSH. I'm writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.