Bawe dating site
function urlsafe_b64encode($string) function urlsafe_b64decode($string) Php version of perl's MIME:: Base64:: URLSafe, that provides an url-safe base64 string encoding/decoding (compatible with python base64's urlsafe methods) Unfortunately my "function" for encoding base64 on-the-fly from 2007 [which has been removed from the manual in favor of this post] had 2 errors!
The first led to an endless loop because of a missing "$feof"-check, the second caused the rare mentioned errors when encoding failed for some reason in larger files, especially when setting fgets($fh, 2) for example.
So the correct function should be: I needed a simple way to obfuscate auto_increment primary keys in databases when they are visible to users in URIs or API calls.
The users should not be able to increment the id in the URL and see the next data record in the database table.
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
Base64-encoded data takes about 33% more space than the original data.
Finally, PHP's default buffer size is 8192 bytes - enough for 143 MIME lines' worth of input.
Conversely, each 76-character MIME-formatted line (not counting the trailing CRLF) contains exactly enough data for 57 bytes of output without needing to retain leftover bits that need prepending to the next line.
What that means is that each line can be decoded independently of the others, and the decoded chunks can then be concatenated together or written out sequentially.
However, this does make the assumption that the encoded data really is MIME-formatted; without that assurance it is necessary to accept that the base64 data won't be so conveniently arranged.
But lower values then 1024 are bad overall because they slow down the whole process, so 4096 will be fine for all purposes, I guess. Here comes the corrected version which I have tested for all kind of files and length (up to 4,5 Gb!
) without any error: @gutzmer at usa dot net Nice idea! The function base64url_decode doesn't pad strings longer than 4 chars.str_pad will only pad the string if the second argument is larger than the length of the original string.