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

function base64_url_encode($input)
    return strtr(base64_encode($input), '+/=', '-_,');
function base64_url_decode($input)
    return base64_decode(strtr($input, '-_,', '+/='));

Refer gist for comments

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP, ReactJS, Tableau, AWS RedShift and Matillion ETL

Based in Melbourne, Australia

Feel free to contact me or _justin_kelly


Leave a comment

Name Notify me of replies by email.