3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $private_key_string = <<<__EOF__ -----BEGIN RSA PRIVATE KEY----- MIIBOwIBAAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvFB/M+o6OwnHGEtz7tL1bz J3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQJAYj3oKc+Scf1cSHUuIYl5 fruFOmgN9yz21/ORGn/noQc4HS04VynMhzojs5MVIGTFVW1KTn8L4CdQ9iIHHPO4 SQIhAPkb7XKPrCif9XnJSa8l2roMzBYbUXQeeMHW46OzehGlAiEA24zJgypJ3F8t FLqRwXLH0eMr1D50vbPWcmeAWx5hjlMCIQCtPIa8jL2k4tjLgPgFHcYmbI/hL85N eoNwCgj05vOVIQIgScOUlNgpdrwXhmZkwE0TK8aanDXbvTzl6QwzSOn9NvcCIQCS zYIZywZTRueYk3YQCTX3ofnQad7M9X2802tWqm0q6A== -----END RSA PRIVATE KEY----- __EOF__; $public_key_string = <<<__EOF__ -----BEGIN PUBLIC KEY----- MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvF B/M+o6OwnHGEtz7tL1bzJ3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQ== -----END PUBLIC KEY----- __EOF__; $private_key = openssl_pkey_get_private($private_key_string); $public_key = openssl_pkey_get_public($public_key_string); if (!$private_key) { echo "Cannot get private key\n"; } if (!$public_key) { echo "Cannot get public key\n"; } $input = "abc"; echo "input: $input\n"; openssl_public_encrypt($input, $crypttext, $public_key); openssl_private_decrypt($crypttext, $decoded, $private_key); echo "encrypted: " . base64_encode($crypttext) . "\n"; echo "decrypted: $decoded\n"; $encrypted_encoded = "0aO2tBOUdXrXkASzjnYKydq+WDj6URLvBdKOhxbkXp2/kRTjOb4cGDxBURLGoJPi53rNlNsk8AVEB9e2AkWF1Q=="; $encrypted = base64_decode($encrypted_encoded); openssl_private_decrypt($encrypted, $decrypted, $private_key); echo "decrypted: $decrypted\n";
based on C9ttT
Output for 7.1.20, 7.2.6
Fatal error: Uncaught Error: Call to undefined function openssl_pkey_get_private() in /in/eqe8c:22 Stack trace: #0 {main} thrown in /in/eqe8c on line 22
Process exited with code 255.
Output for 7.2.0
input: abc encrypted: f1+bjWHI8+J337le/BE17JOwezTNAliVXvaTNNDEfx/dDU1P0svUitIEa3pTD2BB8+4aUEspafq6TaZBTX71Yg== decrypted: abc decrypted:
Output for 7.1.10
input: abc encrypted: yBpA9clGGIHNpSD4BY061iDkb82KpBAqwZT3N0UZl6PEKPkgM56WERKh1Ir+Tt4Itsa7MbaRPRJ023UycgbR4Q== decrypted: abc decrypted:
Output for 7.1.7
input: abc encrypted: KFRb9R1wzM6OSinb+IoKrc4L+juT4iJ6fpMnV2sYogaZgUYkXQZ8uuuT/Ox5QdxFxnMi4czARjXyG3fjGff3Ng== decrypted: abc decrypted:
Output for 7.1.6
input: abc encrypted: h95l/UyWD13fh/0j5gi/2iJTuaQ5+NoXe/3WrJaRJzOzF8V4XbVa0itmek9M4Gra0UN6bnv/y1cGcNQuHZZ0ow== decrypted: abc decrypted:
Output for 7.1.5
input: abc encrypted: TcxfJG4UOu2hT5cP428iE7hMxBWPZJQ8EuteVioM2c50hQAIgFbZw2IDXbfP4gQAvyQf/9yfAJut6GR0FVzdww== decrypted: abc decrypted:
Output for 7.1.0
input: abc encrypted: mLcPIBRAnknPCiwfD5186v8NX17ClQ42SrDjH0CpU2GQZG2RrBBj7ayAMXJAeOhKv8yQygZjI4sGMVXqeKQQ+Q== decrypted: abc decrypted:
Output for 7.0.20
input: abc encrypted: K/4KvcrCsN0lVgj9Ctnq7i1v++JAuOY6d+CV7h6JUZuKAhBCK4KNSOn8wWAkQDPhS0i9wYb9H8xkyCi5Zuv8sg== decrypted: abc decrypted:
Output for 7.0.6
input: abc encrypted: pGxFx7JYFeqZclAdyY7CcHmpuGvXm1nwUXVEXqQW31KkzN1HXCKQGp9y0alTHBm/utx1bue7yrpzkiltlukNWg== decrypted: abc decrypted:
Output for 7.0.5
input: abc encrypted: FHZbEjG7lmRkXorkLe130KKnWiLRwmGn+H4Oh4VtMfu42/hXYDtyHJr+LEbpG+b6iyR5KMTIqu5zqu3BxIyKWg== decrypted: abc decrypted:
Output for 7.0.4
input: abc encrypted: GfFeGQtBJUrNlJwCn4YrMgAttsKuN9zJ20ESNdt1VUkWiylRvNW7f2TQxp0SqT82xowIcy4pxbefIRJULqIKlQ== decrypted: abc decrypted:
Output for 7.0.3
input: abc encrypted: q3mI+ED57DD5L2/DNgoF4wJxjdXi7b/tQ8bqFvOVpN/B3TM8F2m/QMFaMSodh3gSjcUUHj1NBp54/khd+zg9Eg== decrypted: abc decrypted:
Output for 7.0.2
input: abc encrypted: VzdrXu09aN2xwGMcNDe+WT0yOegRD82vrolsTFyzZvIOOnoOOMwhGQE5I1lmIeckBgKaHWAcdebFOD9GE6gSpQ== decrypted: abc decrypted:
Output for 7.0.1
input: abc encrypted: ir6B+gPtdxSYwoaPaSSINtfByWfpX6cgul2y3d1TlPhoBvMKTtz11PPIQ26v0XGuELbpSRbc0zv/yx4+pwTBvw== decrypted: abc decrypted:
Output for 7.0.0
input: abc encrypted: m2Jl2gcWOGWQ0VfGGm+SIRgLrMXIe519oDriJr/U15g3W3shAepZbbHitHzpPb1tM4TF02vLffP6ZMKtHTHRwQ== decrypted: abc decrypted:
Output for 5.6.28
input: abc encrypted: Er0QZOffAtSziKlt8qbDL1GAMviVGf2Sj1lcLBZtXivhvoj/LKsQapEJu0zzJxL7mIqXT7+iUgh3/42qjJa8og== decrypted: abc decrypted:
Output for 5.6.21
input: abc encrypted: z1TxU69g/MyDE73uMJ9Rb+cPrpAX3a3dGLRQU7M1oZMJTkYi4S2DQ9Ab/9oncpGgYO1ltPjLx0JxFr9rIonk+w== decrypted: abc decrypted:
Output for 5.6.20
input: abc encrypted: cnQGwFuq7uitGpFDCH3UcodNJ3X3XU3AGFmx5FJ54WRi9DJ+wSGUDbxyttiXC41g7dep72Sf4rZURO6271p7tw== decrypted: abc decrypted:
Output for 5.6.19
input: abc encrypted: G0jR3fpWAao506B+xYxt84zRzR91aShjZ9Fg0FnoBvu7ZM3o4LXKqDl+2U/Aw5YA8Nc0OLsZjm3imfXv3JxCFw== decrypted: abc decrypted:
Output for 5.6.18
input: abc encrypted: rIlaeT1ayHbDqzwnG+Ev5qhAvc9o3B5/F6XTgGJBTBf1M6l5TX3I5OJVivFBqUiQFz10us05lvfOCmvxW+hyGQ== decrypted: abc decrypted:
Output for 5.6.17
input: abc encrypted: FyLlIUwJ3LexqayFbYTxAUbDGQBju087ABVyR8ofMAv0cy1+PPlASqijNSBLIvm35RJ6NlE1Zbx46E2QCPAUaA== decrypted: abc decrypted:
Output for 5.6.16
input: abc encrypted: gIdQ6zxtY9Yb/AwZA8mC+b1TuLw84d9JYm8hWdu1uuHGv77vbhg33J/ODgSH5Vw2RdFCv3v/t6NyQ9yk5uzKCQ== decrypted: abc decrypted:
Output for 5.6.15
input: abc encrypted: 0/icPnwPoc1lBVSctFYL1wGPwdeA22ePBcovJIRNRRe1dxmHu9ioYN+mNfm+7g61IRQz9Xg/AyFu3EUJbWHOnQ== decrypted: abc decrypted:
Output for 5.6.14
input: abc encrypted: z24xNlfsU2NivAWrquDz2Zz4CLZoiKsQLjo6cjU8KWlA0hrfFltGpwuMR70D798WK4PwoRmF1mtvbQlWCQbK2g== decrypted: abc decrypted:
Output for 5.6.13
input: abc encrypted: E2roWD5GhUo3yS6uTXmRlb4Po1bJKrylA4XjV93l+NMXOiEY/D+jHIEzWUhycrRHXlddWao2q+um0rwSHtWnRQ== decrypted: abc decrypted:
Output for 5.6.12
input: abc encrypted: YHeMire713sa//OjkocCWtL/N9GDZ4vdxvHYifaGimlFLi8/5vvmi+RgCkZOC6BnFXP80cmwKp6HrT+EBeGJbQ== decrypted: abc decrypted:
Output for 5.6.11
input: abc encrypted: HKF3RkNeiLi4xFhJ8nT0jsxXE9a9hNqU1QmOEI7yOcB4BGVapf4dAiHwXd3X4PG5MfprBcBgDFHp0QlC2HYP4w== decrypted: abc decrypted:
Output for 5.6.10
input: abc encrypted: c9oamKmntYzHamNQB67fYcWzYHB1+bPchMeegJbjrAk7Jvt3trBOpxhc4za1uRy5IjaRu4HUWuDs3jWKL7pk9Q== decrypted: abc decrypted:
Output for 5.6.9
input: abc encrypted: hxOvgACtGU8SXG+RxPpP/aFmbsQ9ohPDeQ2TtOfr8UGZaqTrr2pHdl9XAf5RhKHDt8Uyy4us5LBzvOlzD2zVNA== decrypted: abc decrypted:
Output for 5.6.8
input: abc encrypted: vT8hwFPxY6udZFZAOvxbTEgwosSNrpWsvaVqSs1NJi3baIyKQTAzsTcBdqCP7cZJYNt6wWEKzVlksg8QuhChiw== decrypted: abc decrypted:
Output for 5.5.35
input: abc encrypted: quxkNZTRfljs+xJo/8e93x41wOFSJdOYpMmk/qzD0maAHHBSFPTEN+TAh/ubz6NonAEV1TZORLhG5WIowpJ2Rw== decrypted: abc decrypted:
Output for 5.5.34
input: abc encrypted: Ur/Igquq+Amm/Se/NCLd22q9F2e4PzrZYVQQp5MD5DvzlwacIShybdwrbR/tg33unQhcBF3DLof1/g2L5Df0hg== decrypted: abc decrypted:
Output for 5.5.33
input: abc encrypted: CgOQab6TznkaO2NviWd1zm6Hq9TpvKUZkNbKDa3tSMS3We0tkikll6Zn/OgSMKjVYQMogYbnRBfTvfRlHf2LiA== decrypted: abc decrypted:
Output for 5.5.32
input: abc encrypted: JSchb4Q2PZw6zHL7CVUk+SUrbwTbQm9YsZNp527Qow0rj7PVo1RkQ6hg5x+zBB8RwQ0SNvUu1UEC6K7aRy9X3A== decrypted: abc decrypted:
Output for 5.5.31
input: abc encrypted: PXLsm8t6Q0zTJYBJaUDnZ+NSrragDjIAodJ89Xkazp70dmYdr2mPfFWeRNmkAVo0tw+7iqVJLYiRK1YvvpY4Vg== decrypted: abc decrypted:
Output for 5.5.30
input: abc encrypted: olSiXXN7CMAg0INbOOjbMBUEbJRm2qrcGaVk5DSE53Z4x0puGadzcGni+uBWJGo0mxOuVSLbHcCksv1DE/spDw== decrypted: abc decrypted:
Output for 5.5.29
input: abc encrypted: cIVASOxxGPn19ucETF3o4iqObBx3JAVAzwUXby6G1msaXHn5rYdYCClZ9lHnBA4av+JkBX+3IIb9ePEkdpaJFw== decrypted: abc decrypted:
Output for 5.5.28
input: abc encrypted: Y3IJ0QZicQEeJbMk5Gm9Znms46va9g2Mmr+lGqD4cPsy/iL6RAWOdrhxXFCPkbERfctkfXz6QGsfXDVjKr/deQ== decrypted: abc decrypted:
Output for 5.5.27
input: abc encrypted: JsVFK/Dx3YksTdGnn62RBqEZst3K8V4OPbxGYwCaxbwxn+NOzLnvUZ6iwdMnmYgyhZ+yytyqA/R462/bIha+yg== decrypted: abc decrypted:
Output for 5.5.26
input: abc encrypted: fgEFvyBcV7ebLortzxHFGxTlIEoOXSrP0llvq8vXJv6iUNOJI43iqYfQxmMCzd4yP0gMu6oRhUGFdPKX8+xEYw== decrypted: abc decrypted:
Output for 5.5.25
input: abc encrypted: DDLCWyzt/SpjLQe6QZZwY0tOtE0IZdtVnZwiVVvgCv9nCADKiKMk5jWn1wryP/phpd5mTVsEU3Gwdwhf4QnDLQ== decrypted: abc decrypted:
Output for 5.5.24
input: abc encrypted: ualVN7jJ8QBG1ew9A+mQngwt6Z1V27SNKL8mRx+SosO/btwifgsRAiW8g8TBv9XJDxstWawzLioCwbbKuP1O6Q== decrypted: abc decrypted:
Output for 5.4.45
input: abc encrypted: snbo1yzqNCkxSv8bzQIJbSXTszXA9/mVC+n46bqYD7Uyw5rLiW8CvtwCxnSUV9nlNhEn4ByK9WpzaMaKymnwwQ== decrypted: abc decrypted:
Output for 5.4.44
input: abc encrypted: av2Yq2WXKXV34zoutQVp9N5BFWF/g6wKXDbH/2446Obwxm6mq3FCqQkT/co/gzFkHYahPQBrMDf+gXbXxs32iw== decrypted: abc decrypted:
Output for 5.4.43
input: abc encrypted: AOCGueyjdOzBgvTd5dqobzVqCke8lvHIf7agZxHokxyFVQ6qgL49/mSZ1hvZVYcOelRXSWKSH9p0xo3zjOzoyA== decrypted: abc decrypted:
Output for 5.4.42
input: abc encrypted: VCKMQYi4Zad8wOkdKqFUb4o7OblpWN0gZQ9IUmE1p7gEG8ynhv60+/v2KWQnfp7fej65RY9aWT6+uSqcTh0rdQ== decrypted: abc decrypted:
Output for 5.4.41
input: abc encrypted: Y2M1MphDpZ/4viV4lyO59Y9Kjl2jz15PzI2OKfqNH7UeZV/2sQzV4s78rYZKE6ASsDboPHnbvwYpLaSGGh2h6A== decrypted: abc decrypted:
Output for 5.4.40
input: abc encrypted: ORjF0N1Fvq/nmBnuwVqaXXymGdu9ESwiu13HoN5hDhdiBduoGcWrr7Aw7hybenaS0fiWp9BPUW8JF94Nu8bR/w== decrypted: abc decrypted:
Output for 5.4.39
input: abc encrypted: H22ZiTo6ma7lbke6Yxziplf89166ackSQEcwnCRzxsQJljtCZLfTsqzTgXNCoq3ewbr9+Zl8DCxHTA5Kg1UkyA== decrypted: abc decrypted:
Output for 5.4.38
input: abc encrypted: LKV8GQwKak4Zv0+nEL4XWTI5G2y+FskbgmJ7SaoMisZd0gv6FL2eQ1n7GsgOKKe26BcWX1g0swxN7un9KLTO+g== decrypted: abc decrypted:
Output for 5.4.37
input: abc encrypted: vMITBeQ6njUx+FLaZ9K549c2W3yX72ZuUDzPKxJF7VhoqR1zLkOL4nYSat3GFmgpbzvxaMruqyXxsjioVMFhOg== decrypted: abc decrypted:
Output for 5.4.36
input: abc encrypted: wwE03GePgeNydeWTTBE+Tgiy67zhMTwWVtdHu7ymnLJJuMK5RnhM4AaXi6L2M/fNW/9SG1jHSXMcxh00E9OECA== decrypted: abc decrypted:
Output for 5.4.35
input: abc encrypted: baCYDnHhfgpB6t9t7ZS1IxY6Bilc9IlP7ZrLNlvTIzCxq6sTKoTl1GaghE84Ml0UX+n0DSMDYNxaXbzkgoDUyA== decrypted: abc decrypted:
Output for 5.4.34
input: abc encrypted: Qu79bS8Mj5QZifxONdJ71Sjylw03Z0/xtWmRe/gqazPYFfAAFCVoPvuslr3f1yK0RTkD0wjeknq3yopZjYjauw== decrypted: abc decrypted:
Output for 5.4.32
input: abc encrypted: ju8FrQ61GwIzgibO05WTl67j8Yeq8xQKN34gSWOVLRYDuNSHWhf2c4WaJeNSMkp50bZJBkeEWO7P7Zp2ohhjSQ== decrypted: abc decrypted:
Output for 5.4.31
input: abc encrypted: LU0/k793FTnct0yk2Jxb10C8uJi2RmKubRZwP9lS0J0UlFWduW4bniOVSoB9GOtBnWHm41X9NLXouAs7gQX5Vg== decrypted: abc decrypted:
Output for 5.4.30
input: abc encrypted: 0p4sb7EExQtupQdQwRL+e4ca4sn5TrQOfBOx5Hpp5azbxSD0YzM9z+gXpYet1ZmNe2YrQjRJ0O16+xYZyTeh0Q== decrypted: abc decrypted:
Output for 5.4.29
input: abc encrypted: SpcaTzTL94XcdTZ1vZtUlbjShs7VLhPQlAoOfi2xmVqFvblQ+DFj7mWcc0iEK0qmSsTFA7r/PLYITAK6ma0Rdg== decrypted: abc decrypted:
Output for 5.4.28
input: abc encrypted: CxV64FHwjWKLCfPKiKkRmLvL12rZbL3nhn6o5CzqsaTiE2SYz0rEmwSsoyux7jr+574MqckSHe/bjUPLpLUr2Q== decrypted: abc decrypted:
Output for 5.4.27
input: abc encrypted: j/JPoJYP1RRXU3gG24V9o2O2v+W5ObjqsmtrVwkpzwY9J5/3EfBwaWLDyupffkfldRI52TM4w375ybBnLf80rA== decrypted: abc decrypted:
Output for 5.4.26
input: abc encrypted: UM90VzUNt6auqTGRT3NISOSwJ3LEK5nqTxCBMcAcH7Ezco9vfMUvBnTyLVEqSRrVS586HeNEFera3GB4KBa6uQ== decrypted: abc decrypted:
Output for 5.4.25
input: abc encrypted: lx5DZtkzIxc+qtd9/d5Y2ZFaRf95t7nA3ZgTZnEJebTZrJPMfyoI/EQuJhGP9dS+YT5Hm1AR4w7xGaRUCBlncQ== decrypted: abc decrypted:
Output for 5.4.24
input: abc encrypted: wEpmFf7lEBQn+vd5FR+kEr1jZo0QkkjfvdsOwu7orlKfrsvHrgVv5FeaXzUldo//xUSmyQrOgSe1Hi9++LgBhQ== decrypted: abc decrypted:
Output for 5.4.23
input: abc encrypted: Upz0atcXvammRDRreYSieNFeVrNo/MlNLk2pitJebs30FyaoOesLfX1O2/ZeeqnN0ECp+31/jdscTKVXB/Qaag== decrypted: abc decrypted:
Output for 5.4.22
input: abc encrypted: EsdlV6a/Wp24sG97jGxMmBW0fFJxVrP4GAZ0eedoCtFWpWA5Ggz0FQhv3sbeS/pyfI8GCyFYuc530hKqwBI7Ag== decrypted: abc decrypted:
Output for 5.4.21
input: abc encrypted: PT6rygDObmud7WNbH6Q02WEhBUcNmFS/RdaCM8oyDRUmF/nTSukxM7liEpRailpxu7igI3u+hQomAxXnoq4kOw== decrypted: abc decrypted:
Output for 5.4.20
input: abc encrypted: rsism68hQCFsswGAmWO9LfH9zng5kGC2JS1Wa+pXKBZ4M6tcGJ2wFTz6V7PSr0W9/a52sJj/qX8nuUx4XaqTuw== decrypted: abc decrypted:
Output for 5.4.19
input: abc encrypted: M5pABCzmV9jsbn1rlO5RJ19B2r2G6S4m19HWn8c9Fg/i/QbOAS0a8RdaOIE7ptoBjcqFLz8n9ZWIBZBD6gb2TQ== decrypted: abc decrypted:
Output for 5.4.18
input: abc encrypted: v85xclaT1nzxzGUDxn7ESSUZyDV4eLmWrGCsRTg4PkjmJPLiO4I/tPAJxVTS6jifIDMCCNsgTwZiHc/MP5SnAQ== decrypted: abc decrypted:
Output for 5.4.17
input: abc encrypted: Hy32RQUxNLWOlghQ4fZyM6CGBS27TpMzcJ5bNdLfGxiHd2wHJv/eLyqyiNC0nkP7+dIlUl2FB+iK87xxAVKsbA== decrypted: abc decrypted:
Output for 5.4.16
input: abc encrypted: SEuiEiSlhqenmDyZ7wEUe4LVLuIJnBdpW9KJaZDVHlAaq5sjJuqdtUV5x5fTcNizSfo/RKR/dli6LTO7b/Q8nw== decrypted: abc decrypted:
Output for 5.4.15
input: abc encrypted: U8nSstKyUOlhDWfTk7Fnze10uhiw3c5QGhIqrMi5OEpRXODN4BOtJc1jqhhsUCX+x0hEGapKYV6nHCn6NQLq8A== decrypted: abc decrypted:
Output for 5.3.22 - 5.4.14
Fatal error: Call to undefined function openssl_pkey_get_private() in /in/eqe8c on line 22
Process exited with code 255.