Base64 Encode and Decode String in PHP


SUBMITTED BY: Guest

DATE: Aug. 25, 2012, 10:03 p.m.

FORMAT: Text only

SIZE: 346 Bytes

HITS: 1580

  1. function base64url_encode($plainText) {
  2. $base64 = base64_encode($plainText);
  3. $base64url = strtr($base64, '+/=', '-_,');
  4. return $base64url;
  5. }
  6. function base64url_decode($plainText) {
  7. $base64url = strtr($plainText, '-_,', '+/=');
  8. $base64 = base64_decode($base64url);
  9. return $base64;
  10. }

comments powered by Disqus