3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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*", $encstring)) . "<br>"; ?>
Output for 7.0.6 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function mcrypt_module_open() in /in/4EfMO:18 Stack trace: #0 /in/4EfMO(75): OpenFireBlowfish->__construct('70S28ao84z4wGS7') #1 {main} thrown in /in/4EfMO on line 18
Process exited with code 255.
Output for 7.0.5
Encrypted Password string:3b13f0e2f00bacf8ae998004c484ab9dda103cd34f1e899d5f07bb512251d6b9<br>Original Password string:password<br>
Output for 7.0.4
Encrypted Password string:e7dca056dc3c690b195801c8888051a5bb2e320c20a113e8340a9e547a64ab1a<br>Original Password string:password<br>
Output for 7.0.3
Encrypted Password string:04362741b13d43fcebdbb992490cd19037fd4a6a69fd7232f196173c66cebc79<br>Original Password string:password<br>
Output for 7.0.2
Encrypted Password string:5b70603a7d153c8c5b047af70645c632c9a793a478e7cd50b7eefe556f61115f<br>Original Password string:password<br>
Output for 7.0.1
Encrypted Password string:e0227eec6dd786f589f43821343da2d579c10a0bbfd0cc00b6e220e3e151000e<br>Original Password string:password<br>
Output for 7.0.0
Encrypted Password string:4fbb57aa4c53716a9c64d4770e460872ebf94115268d93a4776b44c8ddba0ebe<br>Original Password string:password<br>
Output for 5.1.3 - 5.4.32, 5.5.35, 5.6.21 - 5.6.28
Fatal error: Call to undefined function mcrypt_module_open() in /in/4EfMO on line 18
Process exited with code 255.
Output for 5.6.20
Encrypted Password string:b8a851ab92bb4be9d5b8549d83d302f30150a43c51f5fdb1d25add9e8973ffee<br>Original Password string:password<br>
Output for 5.6.19
Encrypted Password string:a87bc1a18f778d2826e9b768c2c7cf9c2a63c316d54be6d5d2e32d998685a71d<br>Original Password string:password<br>
Output for 5.6.18
Encrypted Password string:623f897da0ab31376977e8c21d95171b10e60b64b7d298f5b5b1d9605702f2f8<br>Original Password string:password<br>
Output for 5.6.17
Encrypted Password string:47ced2002d55e341c93d3054ab2a5c89cb6287e47b2ae0f97667476b9faeb293<br>Original Password string:password<br>
Output for 5.6.16
Encrypted Password string:b51d623f259412db41bf11de2c405c54045b09ed86b422f842ffab3e6046bac5<br>Original Password string:password<br>
Output for 5.6.15
Encrypted Password string:5b543f2b2249a5c368b3f4a2391ba18a5d7815db9626e2157e52e280ca1d325e<br>Original Password string:password<br>
Output for 5.6.14
Encrypted Password string:40958c544c28da05244e4998ed30d21c14c33b373e8037f31fb71823c1fbef36<br>Original Password string:password<br>
Output for 5.6.13
Encrypted Password string:05cdac792311676e70342859ccb2c8c7f78cdb750a4d7a6e5a0c477734341f24<br>Original Password string:password<br>
Output for 5.6.12
Encrypted Password string:973600637c9e47dd1a158eca99d7a44ee12b158ed58e2de2217a11f377e73cfc<br>Original Password string:password<br>
Output for 5.6.11
Encrypted Password string:7716f410448527b9363efedca3cb9afe8bfcbac826b457cc8ed432be298e25a0<br>Original Password string:password<br>
Output for 5.6.10
Encrypted Password string:441fbc7d065a2b23fb40296b3814f66a41069773a98b8c3503015981673c89ef<br>Original Password string:password<br>
Output for 5.6.9
Encrypted Password string:ca691a776a50df3df56ea46871e50fe42f329a96ed1914c7c9f4520d1c1e1eef<br>Original Password string:password<br>
Output for 5.6.8
Encrypted Password string:c4d34b2c0d467ca648c9f8beddaf4a84d310bc073aee0d3fe559d9ac5419d18c<br>Original Password string:password<br>
Output for 5.5.34
Encrypted Password string:6e1599ddd92cc13bec6d86e25db084c27579cfdeab40b47cf16ee42bd05f6f3e<br>Original Password string:password<br>
Output for 5.5.33
Encrypted Password string:cd0debf5b33f177a3651647f9d5dc009cc7fc65a5ae2605a2c171e45fde9d0cb<br>Original Password string:password<br>
Output for 5.5.32
Encrypted Password string:959abb9a3eb5e3f86866629c1e2de7a73eba435c331012505c57c057f09ff47f<br>Original Password string:password<br>
Output for 5.5.31
Encrypted Password string:2ac6dae558c363cff70d4200500939b0184b96f61285d71261e6a8e86f397c8d<br>Original Password string:password<br>
Output for 5.5.30
Encrypted Password string:1e8ffb36e820064a89f648d7ffc644e32b863cdcc702a09425b37021e9438077<br>Original Password string:password<br>
Output for 5.5.29
Encrypted Password string:3ccc08bf648cbdcdb0f4fb2e752b81c7b3e7951fc1d7111e0c2dbf95919944a6<br>Original Password string:password<br>
Output for 5.5.28
Encrypted Password string:555367145488f88562f67ba4b80223ef0236e766d84a29dee4574a2da69706cb<br>Original Password string:password<br>
Output for 5.5.27
Encrypted Password string:bf70375cd00c075bec8025408c58b316ff4536ff57c94b36d29f5e4c2b450c84<br>Original Password string:password<br>
Output for 5.5.26
Encrypted Password string:f7ede98c362c22bfeb429305ff71d8f036dbc4ecf173224fad28d6925914f708<br>Original Password string:password<br>
Output for 5.5.25
Encrypted Password string:2d8c568f5429871959fafa73cdfa7df60e35d8ca6e942153e126d77096f7c78d<br>Original Password string:password<br>
Output for 5.5.24
Encrypted Password string:dbb7987bcfc0e9f3317dd6a89665126716f2cc419259cf3da7a4b3a673c6a0c9<br>Original Password string:password<br>
Output for 5.4.45
Encrypted Password string:49522418ec0635156d6d88cbde2cb234769417361a91bc4b66c935f47296e338<br>Original Password string:password<br>
Output for 5.4.44
Encrypted Password string:9c0f1d3360042535f5f0ccfedcc0134def99ad2c85ba872e195ae43dbcebb88b<br>Original Password string:password<br>
Output for 5.4.43
Encrypted Password string:c172b8f5742499dc84439b77dba03254b7d25459eeb4ca7dca6ac94c0010aa39<br>Original Password string:password<br>
Output for 5.4.38 - 5.4.42

Process exited with code 137.
Output for 5.4.37
Encrypted Password string:39cf3eecc5966e5ea3e96d2c989e21dfe9725390786f62e1a6b44507b2891edc<br>Original Password string:password<br>
Output for 5.4.36
Encrypted Password string:4183d2840309497ce77623083cc890f078a5d341f213055508a8ca7f1d9752cc<br>Original Password string:password<br>
Output for 5.4.35
Encrypted Password string:01a33bcb97b0a24275a3f1af62a826a7c86085adcd58cbe0d5e2c2363b35fc07<br>Original Password string:password<br>
Output for 5.4.34
Encrypted Password string:fa0eb55cc0360d44f5a5196a107abc72cc39e1e7bf106ba6f2ffc8f4e48650c2<br>Original Password string:password<br>
Output for 5.0.0 - 5.1.2
Fatal error: Call to undefined function mcrypt_module_open() in /in/4EfMO on line 18 Fatal error: Call to undefined function mcrypt_module_close() in /in/4EfMO on line 65
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/4EfMO on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/4EfMO on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/4EfMO on line 9
Process exited with code 255.