I am using the two functions below to encode part of a url. I had seen
that someone said base64 can sometimes add newlines in the encoding,
but had little luck finding reference to that using google, but I want
to make sure I am safe.
my url looks like this: http://my.local/index.php/widget/fil...2F0ZWRfbmV3cy9
// functions to code url segments ...
function base64_url_enco de($input) {
return strtr(base64_en code($input), '+/=', '-_.');
}
function base64_url_deco de($input) {
return base64_decode(s trtr($input, '-_.', '+/='));
} 5 6853 wb*******@yahoo .com wrote:
I am using the two functions below to encode part of a url. I had seen
that someone said base64 can sometimes add newlines in the encoding,
but had little luck finding reference to that using google, but I want
to make sure I am safe.
my url looks like this: http://my.local/index.php/widget/fil...2F0ZWRfbmV3cy9
// functions to code url segments ...
function base64_url_enco de($input) {
return strtr(base64_en code($input), '+/=', '-_.');
}
function base64_url_deco de($input) {
return base64_decode(s trtr($input, '-_.', '+/='));
}
I haven't seen any base64 implementations which use a newline character
- and I doubt there are any (it's not a printable character).
But rather then use strstr, just urlencode the results from
base64_encode() .
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
On Jun 6, 3:34 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
wbsurf...@yahoo .com wrote:
I am using the two functions below to encode part of a url. I had seen
that someone said base64 can sometimes add newlines in the encoding,
but had little luck finding reference to that using google, but I want
to make sure I am safe.
my url looks like this: http://my.local/index.php/widget/fil.../aHR0cDovL21lZ...
// functions to code url segments ...
function base64_url_enco de($input) {
return strtr(base64_en code($input), '+/=', '-_.');
}
function base64_url_deco de($input) {
return base64_decode(s trtr($input, '-_.', '+/='));
}
I haven't seen any base64 implementations which use a newline character
- and I doubt there are any (it's not a printable character).
But rather then use strstr, just urlencode the results from
base64_encode() .
uuencode does it (presumably because it was written when line-oriented
terminals were the common way of interacting with data) and MIME does
it (because SMTP is line oriented). But AFAIK the php implementation
doesn't.
It's a handy way to move data around because:
$enc=str_replac e('=','', base64_encode($ data)); // the trailing '=='
is not required
urlencode($enc) === mysql_real_esca pe($enc) === htmlentities($e nc)
=== addslashes($enc ) === stripslashes($e nc) === $enc
C.
C. ( http://symcbean.blogspot.com/) wrote:
On Jun 6, 3:34 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>wbsurf...@yaho o.com wrote:
>>I am using the two functions below to encode part of a url. I had seen that someone said base64 can sometimes add newlines in the encoding, but had little luck finding reference to that using google, but I want to make sure I am safe. my url looks like this: http://my.local/index.php/widget/fil.../aHR0cDovL21lZ... // functions to code url segments ... function base64_url_enco de($input) { return strtr(base64_en code($input), '+/=', '-_.'); } function base64_url_deco de($input) { return base64_decode(s trtr($input, '-_.', '+/=')); }
I haven't seen any base64 implementations which use a newline character - and I doubt there are any (it's not a printable character).
But rather then use strstr, just urlencode the results from base64_encode( ).
uuencode does it (presumably because it was written when line-oriented
terminals were the common way of interacting with data) and MIME does
it (because SMTP is line oriented). But AFAIK the php implementation
doesn't.
It's a handy way to move data around because:
$enc=str_replac e('=','', base64_encode($ data)); // the trailing '=='
is not required
urlencode($enc) === mysql_real_esca pe($enc) === htmlentities($e nc)
=== addslashes($enc ) === stripslashes($e nc) === $enc
C.
Yes, that's a different way to do it. I've always used base64_encode,
mostly out of habit.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Jerry Stuckle wrote:
C. (http://symcbean.blogspot.com/) wrote:
>On Jun 6, 3:34 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>>wbsurf...@yah oo.com wrote: I am using the two functions below to encode part of a url. I had seen that someone said base64 can sometimes add newlines in the encoding, but had little luck finding reference to that using google, but I want to make sure I am safe. my url looks like this: http://my.local/index.php/widget/fil.../aHR0cDovL21lZ...
// functions to code url segments ... function base64_url_enco de($input) { return strtr(base64_en code($input), '+/=', '-_.'); } function base64_url_deco de($input) { return base64_decode(s trtr($input, '-_.', '+/=')); } I haven't seen any base64 implementations which use a newline character - and I doubt there are any (it's not a printable character).
But rather then use strstr, just urlencode the results from base64_encode ().
uuencode does it (presumably because it was written when line-oriented terminals were the common way of interacting with data) and MIME does it (because SMTP is line oriented). But AFAIK the php implementation doesn't.
It's a handy way to move data around because: $enc=str_replac e('=','', base64_encode($ data)); // the trailing '==' is not required urlencode($enc) === mysql_real_esca pe($enc) === htmlentities($e nc) === addslashes($enc ) === stripslashes($e nc) === $enc
C.
Yes, that's a different way to do it. I've always used base64_encode,
mostly out of habit.
the base64_encode function will never add any newline to result string,
but in the description of RFC 2045, base64ed string should be splited by
\r\n every 76 characters.
GuangXiN wrote:
Jerry Stuckle wrote:
>C. (http://symcbean.blogspot.com/) wrote:
>>On Jun 6, 3:34 am, Jerry Stuckle <jstuck...@attg lobal.netwrote: wbsurf...@ya hoo.com wrote: I am using the two functions below to encode part of a url. I had seen that someone said base64 can sometimes add newlines in the encoding, but had little luck finding reference to that using google, but I want to make sure I am safe. my url looks like this: http://my.local/index.php/widget/fil.../aHR0cDovL21lZ... > // functions to code url segments ... function base64_url_enco de($input) { return strtr(base64_en code($input), '+/=', '-_.'); } function base64_url_deco de($input) { return base64_decode(s trtr($input, '-_.', '+/=')); } I haven't seen any base64 implementations which use a newline character - and I doubt there are any (it's not a printable character).
But rather then use strstr, just urlencode the results from base64_encod e().
uuencode does it (presumably because it was written when line-oriented terminals were the common way of interacting with data) and MIME does it (because SMTP is line oriented). But AFAIK the php implementation doesn't.
It's a handy way to move data around because: $enc=str_replac e('=','', base64_encode($ data)); // the trailing '==' is not required urlencode($enc) === mysql_real_esca pe($enc) === htmlentities($e nc) === addslashes($enc ) === stripslashes($e nc) === $enc
C. Yes, that's a different way to do it. I've always used base64_encode, mostly out of habit.
the base64_encode function will never add any newline to result string,
but in the description of RFC 2045, base64ed string should be splited by
\r\n every 76 characters.
This RFC is discussing how to use bas64 encoding in email - which has
absolutely nothing to do with the topic at hand.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: wenmang |
last post by:
Hi,
I ma thinking whether to use Base64 encoding to encode the binary
content in the XML file. I have done some simple calculations, it
seems to me that the size for encoded content increases by ~30%, is
this the drawback for using the encoding scheme?
Thanks.
|
by: Rasmus |
last post by:
In a asp.net site i need to make a url link like this:
http://server.com/test.aspx?base64=c+KAnMOfxZLDqhd2w4DCtMOmwr8hawkCdsK9YH7igqwITuKAmcOhXAcDxbjFoR3Cum/DqwFJRU7DpzbigJlYZD1cJcKBwqgaBsObw6VxMMW9wrTDpD7CpSTDkeKAuuKAlFfDt8W+Jz3CvhM7w5HCjeKAneKAuT3Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc=
I've used the Convert.ToBase64String() to make the...
|
by: Rasmus |
last post by:
In a asp.net site i need to make a url link like this:
http://server.com/test.aspx?base64=c+KAnMOfxZLDqhd2w4DCtMOmwr8hawkCdsK9YH7igqwITuKAmcOhXAcDxbjFoR3Cum/DqwFJRU7DpzbigJlYZD1cJcKBwqgaBsObw6VxMMW9wrTDpD7CpSTDkeKAuuKAlFfDt8W+Jz3CvhM7w5HCjeKAneKAuT3Dn8WTw5zigKErw6QFxaF+wrvDksOkwqjDq1fCrsOewrc=
I've used the Convert.ToBase64String() to make the...
|
by: Jim Brandley |
last post by:
I need to append a short ciphertext string as a query variable encoded so
it's valid for a URL. After encryption, I convert the bytes to Base64.
However, the result includes characters that are invalid for a URL, notably
'+' symbols. So, I have to cycle the output string through
HttpUtility.UrlEncode(). That takes time. I wrote my own URL-safe...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |