daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 407 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. use \Firebase\JWT\JWT;
  3.  
  4. $privateKey = <<<EOD
  5. -----BEGIN RSA PRIVATE KEY-----
  6. MIICXAIBAAKBgQC8kGa1pSjbSYZVebtTRBLxBz5H4i2p/llLCrEeQhta5kaQu/Rn
  7. vuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t0tyazyZ8JXw+KgXTxldMPEL9
  8. 5+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4ehde/zUxo6UvS7UrBQIDAQAB
  9. AoGAb/MXV46XxCFRxNuB8LyAtmLDgi/xRnTAlMHjSACddwkyKem8//8eZtw9fzxz
  10. bWZ/1/doQOuHBGYZU8aDzzj59FZ78dyzNFoF91hbvZKkg+6wGyd/LrGVEB+Xre0J
  11. Nil0GReM2AHDNZUYRv+HYJPIOrB0CRczLQsgFJ8K6aAD6F0CQQDzbpjYdx10qgK1
  12. cP59UHiHjPZYC0loEsk7s+hUmT3QHerAQJMZWC11Qrn2N+ybwwNblDKv+s5qgMQ5
  13. 5tNoQ9IfAkEAxkyffU6ythpg/H0Ixe1I2rd0GbF05biIzO/i77Det3n4YsJVlDck
  14. ZkcvY3SK2iRIL4c9yY6hlIhs+K9wXTtGWwJBAO9Dskl48mO7woPR9uD22jDpNSwe
  15. k90OMepTjzSvlhjbfuPN1IdhqvSJTDychRwn1kIJ7LQZgQ8fVz9OCFZ/6qMCQGOb
  16. qaGwHmUK6xzpUbbacnYrIM6nLSkXgOAwv7XXCojvY614ILTK3iXiLBOxPu5Eu13k
  17. eUz9sHyD6vkgZzjtxXECQAkp4Xerf5TGfQXGXhxIX52yH+N2LtujCdkQZjXAsGdm
  18. B2zNzvrlgRmgBrklMTrMYgm1NPcW+bRLGcwgW2PTvNM=
  19. -----END RSA PRIVATE KEY-----
  20. EOD;
  21.  
  22. $publicKey = <<<EOD
  23. -----BEGIN PUBLIC KEY-----
  24. MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8kGa1pSjbSYZVebtTRBLxBz5H
  25. 4i2p/llLCrEeQhta5kaQu/RnvuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t
  26. 0tyazyZ8JXw+KgXTxldMPEL95+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4
  27. ehde/zUxo6UvS7UrBQIDAQAB
  28. -----END PUBLIC KEY-----
  29. EOD;
  30.  
  31. $token = array(
  32.     "iss" => "example.org",
  33.     "aud" => "example.com",
  34.     "iat" => 1356999524,
  35.     "nbf" => 1357000000
  36. );
  37.  
  38. $jwt = JWT::encode($token, $privateKey, 'RS256');
  39. echo "Encode:\n" . print_r($jwt, true) . "\n";
  40.  
  41. $decoded = JWT::decode($jwt, $publicKey, array('RS256'));
  42.  
  43. /*
  44.  NOTE: This will now be an object instead of an associative array. To get
  45.  an associative array, you will need to cast it as such:
  46. */
  47.  
  48. $decoded_array = (array) $decoded;
  49. echo "Decode:\n" . print_r($decoded_array, true) . "\n";
  50. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top