@ 2014-10-16T20:32:36Z <?php
/**
* Emulate OpenFire Blowfish Class
*/
class OpenFireBlowfish
{
private $key;
private $cipher;
public $enckey = "70S28ao84z4wGS7"; //Hidden Encryption Key of Openfire BlowFish
public $enciv = '';
function __construct($pass)
{
$this->cipher = mcrypt_module_open('blowfish','','cbc','');
$ks = mcrypt_enc_get_key_size($this->cipher);
$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
exit(1);
}
$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
//echo var_dump(unpack('c*',$iv))."\n";
$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);
}
}
// Test OpenFire Blowfish Class
$enckey = "70S28ao84z4wGS7"; //paste your openfire Db passwordKey copied in poin# 3
$enciv = '';
$a = new OpenFireBlowfish($enckey);
$encstring = bin2hex($a->encryptString('password',$enciv)); //enter your password string to encrypt it
echo "Encrypted Password string:".$encstring . "<br>";
echo "Original Password string:".$a->decryptString(pack("H*", "f84cbd64e079a04c0c9368937702d70251a06e7e86852429cfda6235e391febe")) . "<br>";
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Fatal error: Uncaught Error: Call to undefined function mcrypt_module_open() in /in/SUWCJ:18
Stack trace:
#0 /in/SUWCJ(75): OpenFireBlowfish->__construct('70S28ao84z4wGS7')
#1 {main}
thrown in /in/SUWCJ on line 18
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
44.99 ms | 401 KiB | 8 Q