Read Random Post
Showing posts with label Base64. Show all posts
Showing posts with label Base64. Show all posts

Tuesday, July 26, 2011

BASE64URL variant encoding in php

<?php function base64url_encode($data) { 
  return 
rtrim(strtr(base64_encode($data), '+/', '-_'), '='); 
} 

function 
base64url_decode($data) { 
  return 
base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); 
} 
?>