function _encodePassword($plaintext)
    {
        $password = 0x0000;
        $i        = 1;       // char position

        // split the plain text password in its component characters
        $chars = preg_split('//', $plaintext, -1, PREG_SPLIT_NO_EMPTY);
        foreach ($chars as $char) {
            $value        = ord($char) << $i;   // shifted ASCII value
            $rotated_bits = $value >> 15;       // rotated bits beyond bit 15
            $value       &= 0x7fff;             // first 15 bits
            $password    ^= ($value | $rotated_bits);
            $i++;
        }

        $password ^= strlen($plaintext);
        $password ^= 0xCE4B;

        return($password);
    }
function _encodePassword($plaintext)
    {
        $password = 0x0000;
        $i        = 1;       // char position

        // split the plain text password in its component characters
        $chars = preg_split('//', $plaintext, -1, PREG_SPLIT_NO_EMPTY);
        foreach ($chars as $char) {
            $value        = ord($char) << $i;   // shifted ASCII value
            $rotated_bits = $value >> 15;       // rotated bits beyond bit 15
            $value       &= 0x7fff;             // first 15 bits
            $password    ^= ($value | $rotated_bits);
            $i++;
        }

        $password ^= strlen($plaintext);
        $password ^= 0xCE4B;

        return($password);
    }
function _encodePassword ( $ plaintext ) { $ password = 0x0000 ; $ i = 1 ; // char position
 // split the plain text password in its component characters
 $ chars = preg_split ( '//' , $ plaintext , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ chars as $ char ) { $ value = ord ( $ char ) << $ i ; // shifted ASCII value
 $ rotated_bits = $ value >> 15 ; // rotated bits beyond bit 15
 $ value &= 0x7fff ; // first 15 bits
 $ password ^= ( $ value | $ rotated_bits ) ; $ i ++ ; } $ password ^= strlen ( $ plaintext ) ; $ password ^= 0xCE4B ; return ( $ password ) ; }
Based on the algorithm provided by Daniel Rentz of OpenOffice.

@access private
@param string $plaintext The password to be encoded in plaintext.
@return string The encoded password
Based on the algorithm provided by Daniel Rentz of OpenOffice .