Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. Each base64 digit represents exactly 6 bits of data (Source: Wikipedia ).
The passage of Base64 encoded strings isn't ideal in URLs because, while the Base64 alphabet includes A-Z, a-z, and 0-9, it also includes + and /... potentially returning erroneous results when used in a URL. As recommended by RFC 4648 , a Base64URL string (replacing the \ and + with _ and -) can be created using the functions described below. They're referenced in a number of our articles.
1
<?php
2
/*
3
Encoding Text With Base64URL
4
http://www.beliefmedia.com/code/php-snippets/encoding-text-base64url
5
*/
6
7
8
9
}
10
11
12
13
}
See also our Base64 online encoding tool.