3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Main Code By: Khucing Ithem : https://www.facebook.com/backcat * Make with Class by: hrace009 **/ $data = 'Text ini akan di encrypt menggunakan openssl! dan akan di decrypt dengan openssl juga'; $secretKey = 'mykey'; class MyCrypt { public static function safe_encode ($text) { return md5(trim(strtr(base64_encode($text), '+/=', '-_,'))); } public static function safe_decode($text) { return md5(base64_decode(strtr($text, '-_,', '+/='))); } public static function encrypt($data, $secretKey) { $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('AES-256-CBC')); $cipher = openssl_encrypt($data, 'AES-256-CBC', $secretKey, 0, $iv); $safe_cipher = MyCrypt::safe_encode($cipher); $safe_iv = MyCrypt::safe_encode($iv); return $safe_cipher . '::' . $safe_iv; } public static function decrypt($encrypted, $secretKey) { $token = explode('::', $encrypted); $cipher = MyCrypt::safe_decode($token[0]); $iv = MyCrypt::safe_decode($token[1]); $plain = openssl_decrypt($cipher, 'AES-256-CBC', $secretKey, 0, $iv); return trim($plain); } } $encrypted = MyCrypt::encrypt($data, $secretKey); $decrypted = MyCrypt::decrypt($encrypted, $secretKey); var_dump('Encrypted: ' . $encrypted); var_dump('Decrypted: ' . $decrypted); ?>
Output for 7.1.26 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
Fatal error: Uncaught Error: Call to undefined function openssl_random_pseudo_bytes() in /in/r1bfq:21 Stack trace: #0 /in/r1bfq(41): MyCrypt::encrypt('Text ini akan d...', 'mykey') #1 {main} thrown in /in/r1bfq on line 21
Process exited with code 255.
Output for 7.1.7
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 4aa4fee0a1218b28fd8cbdeff5cbabcc::0fac45f398d8b649a70a6681d2e52d9b" string(11) "Decrypted: "
Output for 7.1.6
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 709ed2219da75acef3ac915c438a210e::854794b4851bc4ec20bf40f859beb35e" string(11) "Decrypted: "
Output for 7.1.5
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 70726ebdcf377a0f75d1162172f2b577::80f6fa69d57412e09ac88c2bbac38171" string(11) "Decrypted: "
Output for 7.1.4
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 12ae48eef82a4447dde040949b2bed5a::ccf004f7f8001eb43298da148d6f9d72" string(11) "Decrypted: "
Output for 7.1.3
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 49b3e0f700f987d76c7bbb57dc356acd::c44df45ffe4f5950b29fc1865f96638d" string(11) "Decrypted: "
Output for 7.1.2
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: ea938874c6154f6d02fa24fb1e3fe016::f28c2e9f6209c42aaee2180c75dabed5" string(11) "Decrypted: "
Output for 7.1.1
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: c6015f2eec7f338dc03f9a0b8f074552::d3753c7248707fcd53d6471dae803dbc" string(11) "Decrypted: "
Output for 7.1.0
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 13a6547461f2990f954274c95cc574ee::e7578178344591f0cb916dc81cb3746e" string(11) "Decrypted: "
Output for 7.0.20
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 94a8d777bee5f5ba70ac4f0d19e52625::d3f790c6178c02e5d9ce9a61ed1278ab" string(11) "Decrypted: "
Output for 7.0.18
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: d15588827d37a56829ad6729e88eb521::66d5375fdb4dd176fe00b0eab5d6a8db" string(11) "Decrypted: "
Output for 7.0.17
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: c0c228f1f6e647cc27401e736146e0ea::813e3ef1a700bc5dd1637a6bdaa5f441" string(11) "Decrypted: "
Output for 7.0.16
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: a40f4be2b220e1e1a60a4cb571d95f3b::4284c6d4c2fff903d96732f1bf601466" string(11) "Decrypted: "
Output for 7.0.15
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 440e834366b294b83fc3352cc3d87754::ab2c0e5c3190f776d2f562af275b6ad3" string(11) "Decrypted: "
Output for 7.0.14
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 3ae5fac42a17cff8a006c0e205cfe1e2::478e4113970be0984685338ba059f224" string(11) "Decrypted: "
Output for 7.0.13
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 792c2a4a42b9f1633c6eba9cd3f0fb7a::bf81f46de7df30a7b3c4382a844ab4db" string(11) "Decrypted: "
Output for 7.0.12
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: e2229c4681e192c3146d42b84f9a4f7e::8a1f3f224d46b029287c07e22ca502cb" string(11) "Decrypted: "
Output for 7.0.11
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: f04d21b011de8bd0d7079da85b0d4a32::8abe87ebfdf39fb2b4e4b7c67737cd42" string(11) "Decrypted: "
Output for 7.0.10
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 1196d2693935124e0b9861de14b868b1::65dc3c911aeed3d15afbf1b6056f82aa" string(11) "Decrypted: "
Output for 7.0.9
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 7457a258da8728f6fd74eeec8ac09566::34ba2c346e27bb0ec957330e1ae3983f" string(11) "Decrypted: "
Output for 7.0.8
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 3ddb6c8a966be7100d23828cd0681a6e::eb33643a7bc79c05a14265588b81c122" string(11) "Decrypted: "
Output for 7.0.7
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: ff656eb456536328ac3aa11799d97ef2::36eb71684f348308b64227d147116271" string(11) "Decrypted: "
Output for 7.0.6
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 42ad26ec2cd32d891a6fe9e61c3e1711::d9905bb46e4fd3070219ef3240ab4c2f" string(11) "Decrypted: "
Output for 7.0.5
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: aa1b42a19e48b1c10073ffcff6d28f13::8021e0b0330b1be31508f7612346955a" string(11) "Decrypted: "
Output for 7.0.4
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 8fae47719ada48e53493e9e20de7aa4d::6b2661a72841fa1bae4aaefd708bb4c0" string(11) "Decrypted: "
Output for 7.0.3
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 99fc751b54853042ab18372ececeb367::8e062b2274c09d7226545f617ede6e2a" string(11) "Decrypted: "
Output for 7.0.2
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: 0f19e9f5565f80b29d77bfadcc95080b::6ffc2c7b59bf03e084a2986ec517da7d" string(11) "Decrypted: "
Output for 7.0.1
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: d7e3c2c9ffb433791e6f4151de2f518f::af758db703c1e7390fd68c2b95f54cdc" string(11) "Decrypted: "
Output for 7.0.0
Warning: openssl_decrypt(): IV passed is 32 bytes long which is longer than the 16 expected by selected cipher, truncating in /in/r1bfq on line 36 string(77) "Encrypted: ca48aba1c8602d839dd610b8bc1b3771::1fcbd753259dd6771976b4537cab17a2" string(11) "Decrypted: "

preferences:
162.59 ms | 402 KiB | 203 Q