Simple PHP base64 encode/decode url safe functions : How to

After searching through the php base64 comments I found the best way to safely encode and decode base64 url components

<?php
function base64_url_encode($input)
{
    return strtr(base64_encode($input), '+/=', '-_,');
}
function base64_url_decode($input)
{
    return base64_decode(strtr($input, '-_,', '+/='));
}
?>

Refer gist for comments https://gist.github.com/justinkelly/1219265

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly

Comments

Leave a comment

Name Notify me of replies by email.