Base64 Encode and Decode String/Url

Public

These functions maybe used to produce base64 encoded urls.

</> CopyGet raw version
php
  1. function base64url_encode($string) {
  2. $base64 = base64_encode($string);
  3. $base64url = strtr($base64, '+/=', '-_,');
  4. return $base64url;
  5. }
  6.  
  7. function base64url_decode($string) {
  8. $base64url = strtr($string, '-_,', '+/=');
  9. $base64 = base64_decode($base64url);
  10. return $base64;
  11. }